power2go.js

////////////////////////////////////////////////////////////////////////////////
//
// global variables
//
////////////////////////////////////////////////////////////////////////////////
//default capacity
var DEFAULT_DATA_CAPACITY = 4482;
var DEFAULT_AUDIO_CAPACITY = 4440000;

//is initing
var g_bIniting = false;
//is dropping file
var g_bDropping = false;
//is animating
var g_bAnimating = false;
//is burning
var g_bBurning = false;
//can current project be burnt
var g_bCanBurn = false;
//store the burning image path
var g_sBurningImagePath = “”;

//project control
var P2GO_TASK_NONE = 0;
var P2GO_TASK_DATA = 1;
var P2GO_TASK_AUDIOCD = 2;
var P2GO_TASK_DVDV = 5;
var P2GO_TASK_VCD = 6;
var P2GO_TASK_DISC_COPY = 9;
var P2GO_TASK_BURN_IMG = 11;
var g_nActiveProject = P2GO_TASK_NONE;

//message control
var P2GO_GADGET_ADD_FILE = 3;
var P2GO_GADGET_START_DIALOG = 5;
var P2GO_GADGET_START_BURN = 6;

//stop burn disc control
var AUTOCANCEL = 1;
var NOTAUTOCANCEL = 0;

//op code
var OP_WRITE_NORMAL = 8;
var OP_WRITE_SIMULATE = 11;
var OP_WRITE_VERIFY = 13;
var OP_ENCODING = 100;
var OP_READING = 101;

//P2GoGadget.dll
var control = null;

//store current burner count in the system
var g_nBurnerCount = 0;

////////////////////////////////////////////////////////////////////////////////
//
// common function
//
////////////////////////////////////////////////////////////////////////////////
//enable/disable top navigator
function enableControls(bVisible)
{
if(g_bBurning)
bVisible = false;

with(imgLeftArrow)
{
if(bVisible)
style.visibility = “visible”;
else
style.visibility = “hidden”;
}

with(imgRightArrow)
{
if(bVisible)
style.visibility = “visible”;
else
style.visibility = “hidden”;
}

with(imgAPButton)
{
if(bVisible)
style.visibility = “visible”;
else
style.visibility = “hidden”;
}
}

//check system has at least one burner
function hasBurner(bEnumBurner)
{
if(bEnumBurner)
control.enumBurner();

if(control.getBurnerCount() > 0)
return true;
return false;
}

//set button tooltip
function setTooltip()
{
imgAPButton.title = L_TOOLTIP_APBUTTON_TEXT;
imgBurnButton.title = L_TOOLTIP_BURNBUTTON_TEXT;
}

////////////////////////////////////////////////////////////////////////////////
//
// set active project function
//
////////////////////////////////////////////////////////////////////////////////
//set current/avtive project
function setActiveProject(nActiveProject, bUpdateCapacityInfo)
{
//init variables
g_bBurning = false;
g_bAnimating = false;

g_nActiveProject = nActiveProject;

if(P2GO_TASK_DATA == nActiveProject)
{
g_arrayIconImages = g_arrayDataIconImages;
textTaskTitle.innerHTML = L_DATADISC_TEXT;
imgDisc.src = “images/data_cd.png”;
imgIcon.src = “images/data_icon.png”;
imgIcon.title = L_TOOLTIP_DATADISC_TEXT;

imgLeftArrow.title = L_DISCCOPY_TEXT;
if(control.getHideMPEGAudioRelatedTasks())
imgRightArrow.title = L_DISCCOPY_TEXT;
else
imgRightArrow.title = L_MUSICDISC_TEXT;
}
else if(P2GO_TASK_AUDIOCD == nActiveProject)
{
g_arrayIconImages = g_arrayAudioIconImages;
textTaskTitle.innerHTML = L_MUSICDISC_TEXT;
imgDisc.src = “images/audio_cd.png”;
imgIcon.src = “images/audio_icon.png”;
imgIcon.title = L_TOOLTIP_MUSICDISC_TEXT;

imgLeftArrow.title = L_DATADISC_TEXT;
if(!control.getShowVideoPhotoDisc())
imgRightArrow.title = L_DISCCOPY_TEXT;
else
imgRightArrow.title = L_VIDEODISC_TEXT;
}
else if(P2GO_TASK_DVDV == nActiveProject || P2GO_TASK_VCD == nActiveProject)
{
g_arrayIconImages = g_arrayVideoIconImages;
textTaskTitle.innerHTML = L_VIDEODISC_TEXT;
imgDisc.src = “images/video_cd.png”;
imgIcon.src = “images/video_icon.png”;
imgIcon.title = L_TOOLTIP_VIDEODISC_TEXT;

imgLeftArrow.title = L_MUSICDISC_TEXT;
imgRightArrow.title = L_DISCCOPY_TEXT;
}
else if(P2GO_TASK_DISC_COPY == nActiveProject || P2GO_TASK_BURN_IMG == nActiveProject)
{
g_arrayIconImages = g_arrayCopyIconImages;
textTaskTitle.innerHTML = L_DISCCOPY_TEXT;
imgDisc.src = “images/copydisc_cd.png”;
imgIcon.src = “images/copydisc_icon.png”;
imgIcon.title = L_TOOLTIP_DISCCOPY_TEXT;

if(control.getHideMPEGAudioRelatedTasks())
imgLeftArrow.title = L_DATADISC_TEXT;
else if(!control.getShowVideoPhotoDisc())
imgLeftArrow.title = L_MUSICDISC_TEXT;
else
imgLeftArrow.title = L_VIDEODISC_TEXT;
imgRightArrow.title = L_DATADISC_TEXT;
}

control.setActiveProject(nActiveProject);

if(bUpdateCapacityInfo)
{
updateCapacityInfo(g_nActiveProject);
updateCapacityInfoImage(g_nActiveProject, g_nUsedSpace, g_nDiscCapacity, g_bCanBurn);
}
}

////////////////////////////////////////////////////////////////////////////////
//
// update capacity function
//
////////////////////////////////////////////////////////////////////////////////
//convert ms to minutes:seconds
function durationFormatMs(nTotalMs)
{
var nMs = nTotalMs % 1000;
var nSec = nTotalMs / 1000;
var nMin = nSec / 60;
var nSec = nSec % 60;

return nMin.toFixed(0) + “:” + nSec.toFixed(0);
}

//used space and disc capcity of current project
var g_nUsedSpace = 0;
var g_nDiscCapacity = 0;
//update used space & disc capacity
function updateCapacityInfo(nActiveProject)
{
if(P2GO_TASK_DISC_COPY == nActiveProject || P2GO_TASK_BURN_IMG == nActiveProject)
{
with(textCapacityInfo)
{
style.visibility = “hidden”;
}

if(hasBurner(false))
g_bCanBurn = true;
}
else
{
with(textCapacityInfo)
{
style.visibility = “visible”;
}

if(g_bIniting)
{
//update capacity from default value
g_nUsedSpace = 0;
if(P2GO_TASK_DATA == nActiveProject)
{
g_nDiscCapacity = DEFAULT_DATA_CAPACITY;
}
else if(P2GO_TASK_AUDIOCD == nActiveProject)
{
g_nDiscCapacity = DEFAULT_AUDIO_CAPACITY;
}
else if(P2GO_TASK_DVDV == nActiveProject || P2GO_TASK_VCD == nActiveProject)
{
g_nDiscCapacity = DEFAULT_DATA_CAPACITY;
}
}
else
{
//update capacity from express mode server
control.updateCapacityInfo();
g_nUsedSpace = control.getUsedSpace();
g_nDiscCapacity = control.getDiscCapacity();
}

if(P2GO_TASK_DATA == nActiveProject || P2GO_TASK_DVDV == nActiveProject || P2GO_TASK_VCD == nActiveProject)
{
if(g_nDiscCapacity < 1024)
{
textCapacityInfo.innerHTML = g_nUsedSpace + “/” + g_nDiscCapacity + L_MB_TEXT;
}
else
{
var fUsedSpace = g_nUsedSpace/1024;
var fDiscCapacity = g_nDiscCapacity/1024;
textCapacityInfo.innerHTML = fUsedSpace.toFixed(2) + “/” + fDiscCapacity.toFixed(2) + L_GB_TEXT;
}
}
else
{
textCapacityInfo.innerHTML = durationFormatMs(g_nUsedSpace) + “/” + durationFormatMs(g_nDiscCapacity) + L_MIN_TEXT;
}

if(g_bIniting)
  g_bCanBurn = false;
else
  g_bCanBurn = control.getCanBurn();

}
}

//set backdisc image to black or red
function setBackDiscImage(nActiveProject, nPercent, nDiscCapacity)
{
if(!hasBurner(false))
imgBackDisc.src = “images/backdisc1.png”;
else if(P2GO_TASK_DISC_COPY == nActiveProject || P2GO_TASK_BURN_IMG == nActiveProject)
imgBackDisc.src = “images/backdisc1.png”;
else if(nPercent >= 0 && nPercent <= 100 || nDiscCapacity == 0)
imgBackDisc.src = “images/backdisc1.png”;
else
imgBackDisc.src = “images/backdisc2.png”;
}

//set burn button image
function setBurnButtonImage(bCanBurn)
{
if(!bCanBurn)
imgBurnButton.src = “images/burn1.png”;
else
imgBurnButton.src = “images/burn2.png”;
}

//update images by capacity info
function updateCapacityInfoImage(nActiveProject, nUsedSpace, nDiscCapacity, bCanBurn)
{
var nPercent = ((nUsedSpace/nDiscCapacity) * 100).toFixed(0);

setBackDiscImage(nActiveProject, nPercent, nDiscCapacity);
setBurnButtonImage(bCanBurn);

if(nPercent >= 0)
{
if(nPercent > 100)
nPercent = 100;

if(control.getDisableGadgetDiscAnimation())
{
imgDisc2.src = “images/onepixel.png”
}
else if(P2GO_TASK_DATA == nActiveProject)
{
imgDisc2.src = findImage(“data_disc”, “data_disc”, nPercent);
}
else if(P2GO_TASK_AUDIOCD == nActiveProject)
{
imgDisc2.src = findImage(“audio_disc”, “audio_disc”, nPercent);
}
else if(P2GO_TASK_DVDV == nActiveProject || P2GO_TASK_VCD == nActiveProject)
{
imgDisc2.src = findImage(“video_disc”, “video_disc”, nPercent);
}
else if(P2GO_TASK_DISC_COPY == nActiveProject || P2GO_TASK_BURN_IMG == nActiveProject)
{
imgDisc2.src = “images/onepixel.png”
}

g_nLastPercent = nPercent;
}
}

//store last percent value
var g_nLastPercent = 1;
//update images for the percentage of current used space/disc capacity
function updateCapacityInfoAnimationImage(nActiveProject, nUsedSpace, nDiscCapacity, bCanBurn)
{
var nPercent = ((nUsedSpace/nDiscCapacity) * 100).toFixed(0);

setBackDiscImage(nActiveProject, nPercent, nDiscCapacity);
setBurnButtonImage(bCanBurn);

if(nPercent >= 0)
{
if(nPercent > 100)
nPercent = 100;

if(P2GO_TASK_DATA == nActiveProject)
{
g_arrayDiscImages = setAnimationImages(“data_disc”, “data_disc”, g_nLastPercent, nPercent);
}
else if(P2GO_TASK_AUDIOCD == nActiveProject)
{
g_arrayDiscImages = setAnimationImages(“audio_disc”, “audio_disc”, g_nLastPercent, nPercent);
}
else if(P2GO_TASK_DVDV == nActiveProject || P2GO_TASK_VCD == nActiveProject)
{
g_arrayDiscImages = setAnimationImages(“video_disc”, “video_disc”, g_nLastPercent, nPercent);
}

g_nLastPercent = nPercent;
}
}

////////////////////////////////////////////////////////////////////////////////
//
// animation handling
//
////////////////////////////////////////////////////////////////////////////////
//find a image
function findImage(sDir, sPrefix, i)
{
if(i < 10)
{
return “images/” + sDir + “/” + sPrefix + “000” + i + “.png”;
}
else if(i < 100)
{
return “images/” + sDir + “/” + sPrefix + “00” + i + “.png”;
}
else
{
return “images/” + sDir + “/” + sPrefix + “0” + i + “.png”;
}
}

//set image array for animation
function setAnimationImages(sDir, sPrefix, nStart, nEnd)
{
var arrayImages = new Array();
var j = 0;
for(i=nStart; i<=nEnd; i++)
{
if(i < 10)
{
arrayImages[j] = “images/” + sDir + “/” + sPrefix + “000” + i + “.png”;
}
else if(i < 100)
{
arrayImages[j] = “images/” + sDir + “/” + sPrefix + “00” + i + “.png”;
}
else
{
arrayImages[j] = “images/” + sDir + “/” + sPrefix + “0” + i + “.png”;
}

//control.debug(arrayImages[j]);
j++;

}

return arrayImages;
}

//current frame index
var g_nDiscFrame = 0;
//store animation images
var g_arrayDiscImages;
//start animation
function startDiscAnimation()
{
if(g_nDiscFrame < g_arrayDiscImages.length)
{
g_bAnimating = true;
imgDisc2.src = g_arrayDiscImages[g_nDiscFrame++];
setTimeout(“startDiscAnimation()”, 50);
}
else
{
g_nDiscFrame=0;
g_bAnimating = false;
}
}

//current frame index
var g_nIconFrame = 0;
//store animation images
var g_arrayIconImages;
//start animation
function startIconAnimation()
{
if(g_nIconFrame < g_arrayIconImages.length)
{
g_bAnimating = true;
imgIcon.src = g_arrayIconImages[g_nIconFrame++];
setTimeout(“startIconAnimation()”, 50);
}
else
{
g_nIconFrame=0;
g_bAnimating = false;
}
}

//current frame index
var g_nBurnButtonFrame = 0;
//store animation images
var g_arrayBurnButtonImages = null;
//start animation
function startBurnButtonAnimation()
{
if(g_nBurnButtonFrame < g_arrayBurnButtonImages.length)
{
g_bAnimating = true;
imgBurnButton.src = g_arrayBurnButtonImages[g_nBurnButtonFrame++];
setTimeout(“startBurnButtonAnimation()”, 50);
}
else
{
g_nBurnButtonFrame=0;
g_bAnimating = false;
}
}

//array for the project icon animation
var g_arrayDataIconImages = null;
var g_arrayAudioIconImages = null;
var g_arrayVideoIconImages = null;
var g_arrayCopyIconImages = null;
//init animation images
function initAnimationImage()
{
g_arrayDataIconImages = setAnimationImages(“data”, “data”, 1, 38);
g_arrayAudioIconImages = setAnimationImages(“audio”, “audio”, 1, 38);
g_arrayVideoIconImages = setAnimationImages(“video”, “video”, 1, 38);
g_arrayCopyIconImages = setAnimationImages(“copy”, “copy”, 1, 38);

g_arrayBurnButtonImages = setAnimationImages(“flamer”, “flamer”, 1, 22);
}

////////////////////////////////////////////////////////////////////////////////
//
// polling function
//
////////////////////////////////////////////////////////////////////////////////
//update gadget display during buring progress
//P2GO_GADGET_START_BURN: init value set by P2GoGadget.dll
//1: start burning
//0: cancel burning/finish burning
//(this value would always be set to 1 or 0 by express mode server)
function updateBurningDisplay()
{
if(P2GO_GADGET_START_BURN == control.getBurningState())
{
textBurningProgress.innerHTML = “0%”;
textBurningState.innerHTML = L_BURNING_TEXT;

setTimeout("updateBurningDisplay()", 500);

}
else if(1 == control.getBurningState())
{
var nBurningCode = control.getBurningCode()
var nBurningProgress = control.getBurningProgress();
textBurningProgress.innerHTML = nBurningProgress + “%”;

if(nBurningProgress &gt;= 0 &amp;&amp; nBurningProgress &lt; 100)
{
  if(OP_WRITE_SIMULATE == nBurningCode)
    textBurningState.innerHTML = L_SIMULATING_TEXT;
  else if(OP_WRITE_VERIFY == nBurningCode)
    textBurningState.innerHTML = L_VERIFYING_TEXT;
  else if(OP_ENCODING == nBurningCode)
    textBurningState.innerHTML = L_ENCODING_TEXT;
  else if(OP_READING == nBurningCode)
    textBurningState.innerHTML = L_READING_TEXT;
  else
    textBurningState.innerHTML = L_BURNING_TEXT;
}
else if(nBurningProgress == 100)
{
  textBurningState.innerHTML = L_COMPLETED_TEXT;
}

setTimeout("updateBurningDisplay()", 500);

}
else if(0 == control.getBurningState())
{
g_bBurning = false;
setActiveProject(g_nActiveProject, true);
imgCover.src = “images/onepixel.png”;
textBurningProgress.innerHTML = “”;
textBurningState.innerHTML = “”;
}
}

//update gadget status when dialog is closed
function pollingDialog()
{
//—- copy and modify from “function mouseoverBurnButton()” —-
if(P2GO_GADGET_START_DIALOG == control.getDialogState() || 1 == control.getDialogState())
imgBurnButton.src = “images/burn1.png”;
else if(!g_bCanBurn)
imgBurnButton.src = “images/burn1.png”;
else
imgBurnButton.src = “images/burn2.png”;
//—- copy and modify from “function mouseoverBurnButton()” —-

if(P2GO_GADGET_START_DIALOG == control.getDialogState())
{
setTimeout(“pollingDialog()”, 1000);
}
else if(1 == control.getDialogState())
{
setTimeout(“pollingDialog()”, 1000);
}
else if(0 == control.getDialogState())
{
//user may press burn button in the dialog
if(1 == control.getBurningState())
{
startBurn(false);
}
else
{
setActiveProject(g_nActiveProject, true);
}
}
}

////////////////////////////////////////////////////////////////////////////////
//
// main html handling
//
////////////////////////////////////////////////////////////////////////////////
//init gadget
function loadMain()
{
g_bIniting = true;

//—- set gadget —-
System.Gadget.background = “url(../images/gadget_bg.png)”;
System.Gadget.settingsUI = “settings.html”;
//—- set gadget —-

setTimeout(loadData, 0);
}

function loadData()
{
//—- set event —-
for(i=0; i<document.all.length; i++)=”” {=”” if(null=”=” document.all[i].ondragenter)=”” document.all[i].ondragenter=”dragenterMain;” document.all[i].ondragover)=”” document.all[i].ondragover=”dragoverMain;” }=”” —-=”” set=”” event=”” activexobject=”” try=”” control=”new” activexobject(“cyberlink.p2gogadget”);=”” catch(e)=”” registerp2gogadget();=”” start=”” expressmodeserver=”” control.startexpressmodeserver();=”” activeproject=”” mysetting.load();=”” if(p2go_task_none=”=” mysetting.activeproject)=”” setactiveproject(p2go_task_data,=”” true);=”” else=”” setactiveproject(mysetting.activeproject,=”” if(control.getoemlogo())=”” imglogobutton.src=”images/logo_oem.png” ;=”” settooltip();=”” init=”” animationimage=”” initanimationimage();=”” g_biniting=”false;” function=”” unloadmain()=”” if(g_bburning=”” &&=”” 1=”=” control.getburningstate())=”” control.stopburn(autocancel);=”” control.stopexpressmodeserver();=”” file=”” drop=”” dropmain()=”” if(g_bdropping)=”” return;=”” if(!hasburner(true))=”” if(1=”=” control.getburningstate()=”” ||=”” control.getdialogstate())=”” g_bdropping=”true;” setactiveproject(g_nactiveproject,=”” false);=”” var=”” item;=”” i=”0;” do=”” item=”System.Shell.itemFromFileDrop(event.dataTransfer,” i++);=”” !=”item)” if(p2go_task_disc_copy=”=” g_nactiveproject=”” p2go_task_burn_img=”=” g_nactiveproject)=”” control.addfile(item.path,=”” true,=”” pollingdialog();=”” break;=”” itemnext=”System.Shell.itemFromFileDrop(event.dataTransfer,” i);=”” itemnext)=”” false,=”” }while(null=”” dropanimation();=”” animation=”” dropanimation()=”” if(p2go_gadget_add_file=”=” control.getacceptfilestate())=”” settimeout(“dropanimation()”,=”” 500);=”” if(control.getacceptfilestate())=”” starticonanimation();=”” startburnbuttonanimation();=”” always=”” update=”” capacity=”” info=”” when=”” is=”” added=”” updatecapacityinfo(g_nactiveproject);=”” disc=”” if(!control.getdisablegadgetdiscanimation())=”” updatecapacityinfoanimationimage(g_nactiveproject,=”” g_nusedspace,=”” g_ndisccapacity,=”” g_bcanburn);=”” startdiscanimation();=”” drag=”” enter=”” dragentermain()=”” event.returnvalue=”false;” over=”” dragovermain()=”” left=”” arrow=”” button=”” handling=”” mouseoverleftarrow()=”” imgleftarrow.src=”images/l_arrow2.png” mouseoutleftarrow()=”” clickleftarrow()=”” if(g_banimating)=”” if(p2go_task_data=”=” setactiveproject(p2go_task_disc_copy,=”” if(p2go_task_audiocd=”=” if(p2go_task_dvdv=”=” p2go_task_vcd=”=” setactiveproject(p2go_task_audiocd,=”” if(control.gethidempegaudiorelatedtasks())=”” if(!control.getshowvideophotodisc())=”” setactiveproject(p2go_task_dvdv,=”” remember=”” current=”” project=”” setting=”” mysetting.activeproject=”g_nActiveProject;” mysetting.save();=”” right=”” mouseoverrightarrow()=”” imgrightarrow.src=”images/r_arrow2.png” mouseoutrightarrow()=”” clickrightarrow()=”” ap=”” mouseoverapbutton()=”” imgapbutton.src=”images/ap2.png” mouseoutapbutton()=”” clickapbutton()=”” control.startdialog();=”” burn=”” mouseoverburnbutton()=”” imgburnbutton.src=”images/burn1.png” if(!g_bcanburn)=”” mouseoutburnbutton()=”” clickburnbutton()=”” control.stopburn(notautocancel);=”” startburn(true);=”” startburn(bsendmessage)=”” ui=”” g_bburning=”true;” enablecontrols(false);=”” user=”” may=”” press=”” in=”” the=”” dialog,=”” so=”” we=”” don’t=”” need=”” to=”” sendmessage=”” again=”” this=”” case.=”” if(bsendmessage)=”” control.startburn();=”” imgcover.src=”images/burning_cover.png” updateburningdisplay();=”” <=”” p=””></document.all.length;>

Published by Michael Jones

One love, I want to further illustrate the importance of idenity and communication to me. I understand communication to drive and act as a catalyst for diversifying pros. This in the context of being about me proves to me the necessary ambiguity and of course the "leader intensive" roles of communication. During my undergrad I had a chance further education for a blog, and one thing I remember is it told me that writing is intensive and requires communication. Amid it as it is to be when projected to describe communication as the corner stone for the better evolution. With this being said, I am communication as gorged is important and Techrepublic similar, states this by saying, maintaining regular and open communication smooths the flow of instructions. Sparking this conscious recedes from an early assessment or preparation to become a person. This in-part was presented by researching about writers and my understanding of compliance and leading as the "Leader", but more importantly communication, because the essential progress is the indicator anything is being communicated. In ways communication needs to be received and understood. This proactive approach to communication ensures the success of the Communication in all talks. The relation an at many levels a great importance, because it inhibits the ability to address goals, objectives, and again flow. Rather the documented writing address aspects and topics: Keyed, results, quality reviews, etc. I am the plan, is the concern, which sets a reasonable expectation for speech in regards to project communication.