/*************************** mecoScript.js *******************************
**** Version 1.01.0001
**** last changed 04.03.2008
**** (c) 2007/2008 Bernd Rudolf, econtio GmbH, www.econtio.de
*************************************************************************/
var scriptList=new Object();var scriptStack=new Array();var runningScript=null;function appResult(b,g,e,a){meco.debuglog("<b>appResult</b>: "+b+"<br/>Function: "+g+" / Details: "+e+"<br/>Value: "+a);if(b==0){switch(g.toUpperCase()){case"GET":mecoVariables[e]=a;break;case"SET":mecoVariables[e]=a;break;case"SETFULLSCREEN":mecoVariables.FULLSCREEN=a;break;case"CREATEINSTALLPATH":mecoVariables.INSTALL_PATH=a+"\\";break;case"LOADVARIABLES":var d=a.split("&");for(var c=0;c<d.length;c++){myVar=d[c].split("=");meco.debuglog("...setting: "+myVar[0]+"="+myVar[1]);mecoVariables[myVar[0]]=myVar[1];}break;case"LISTVARIABLES":var d=a.split("&");for(var c=0;c<d.length;c++){myVar=d[c].split("=");meco.debuglog("...setting: "+myVar[0]+"="+myVar[1]);mecoVariables[myVar[0]]=myVar[1];}break;case"EVENTMEDIAREMOVED":ejectDVD();break;case"EVENTMEDIAINSERTED":mecoVariables.DVDVOLUME=e;mecoVariables.ROM_PATH=a;var f=e.split("_");if(f[0]!=mecoVariables.PROJECT_NAME){alert(getMecoString("wrongDVD"));}else{meco.execCommand("meco:set('DVDACTIVE', '"+f[1]+"')");meco.switchDVD(e,(mecoVariables.DVDACTIVE!=f[1]));}break;case"CHECKNETWORK":mecoVariables.ONLINE=a;break;case"SAVE":mecoVariables.USER_FILENAME=a;break;case"LOAD":mecoVariables.USER_FILENAME=a;break;case"DECODEKEY":meco.decodeKey=a;break;case"CHECKKEY":meco.checkKey=a;break;}if(runningScript&&runningScript.active){runningScript.next(b,g,e,a);}else{if(!!meco.callBack&&typeof(meco.callBack=="function")){temp=meco.callBack;meco.callBack=null;temp(b,g,e,a);}}}else{if(b==-1){return;}if(b==-90){meco.debuglog("Error: unknown Command: "+g);runningScript.bFatalError=true;}else{if(mecoError&&mecoError[g]){meco.debuglog(g+": Error ("+b+") <br/>"+mecoError[g][b]+"<br/><b>Usage:</b> "+mecoError[g][0]);}switch(g){case"get":break;case"createInstallPath":runningScript.bFatalError=true;break;case"checkROM":if(confirm(getMecoString("insertDVD"))){runningScript.abort();restartApp();}else{abortApp();}break;case"checkKey":alert(getMecoString("keyInvalid"));meco.checkKey=-1;default:runningScript.bFatalError=true;break;}}if(runningScript&&runningScript.active&&runningScript.bFatalError){if(meco.userHandleError(b,g,e,a,runningScript)){runningScript.abort();}else{runningScript.next(b,g,e,a);}}else{if(!!meco.callBack&&typeof(meco.callBack=="function")){temp=meco.callBack;meco.callBack=null;temp(b,g,e,a);}}}}var mecoScript=function(b,a){this.name=b;this.bdebug=true;this.script=a;this.init=function(){this.step=0;this.active=false;this.mecoIf=false;this.bFatalError=false;};this.init();this.done=function(){};this.scriptComplete=function(d,f,e,c){this.active=false;if(this.bdebug){meco.debuglog("### Script "+this.name+" done!");}if(scriptStack.length>0){runningScript=scriptStack.pop();if(this.bdebug){meco.debuglog("*** continuing with script "+runningScript.name+"...");}runningScript.exec(runningScript.step);}else{this.done();}};this.abort=function(d,f,e,c){this.active=false;if(this.bdebug){meco.debuglog("script '"+this.name+"' stopped at line "+(this.step+1));}if(this.bFatalError){mainDebug.adjustDisplay(true);mainDebug.switchSubElement(meco.debugElement.id);}if(scriptStack.length>0){if(!this.bFatalError){runningScript=scriptStack.pop();meco.debuglog("*** aborting script "+runningScript.name+" due to fatal error...");runningScript.bFatalError=true;runningScript.abort();}}};this.go=function(){if(!this.active){meco.debuglog("*** entering Script "+this.name);this.init();this.active=true;if(this.bdebug){var d="";for(var c=0;c<this.script.length;c++){d=d+this.script[c]+"  ";}meco.debuglog(d);}this.step=0;if(this.script.length>0){this.exec(0);}else{if(this.bdebug){meco.debuglog("Script ist leer!");}}}else{}};this.exec=function(e){var c=this.script[e];meco.debuglog("exec: "+c);var f=c.substr(0,c.indexOf(":")+1);if(f!="meco:"){this.mecoIf=false;switch(f){case"meco-if:":this.mecoIf=true;c=c.replace(/meco-if:/,"meco:");var d=this.step+1;var g=0;while(d<this.script.length){if(this.script[d].substr(0,8)=="meco-if:"){g++;}endifComp=(this.script[d].substr(0,11)=="meco-endif:");if(this.script[d].substr(0,10)=="meco-else:"||endifComp){if(g==0){this.stepElse=d+1;break;}if(endifComp){g--;}}d++;}meco.debuglog("stepElse is: ["+this.stepElse+"] "+this.script[this.stepElse]);if(d>=this.script.length){meco.debuglog("Error in line "+this.step+": if without else/endif");}break;case"meco-else:":var d=this.step+1;while(d<this.script.length){if(this.script[d].substr(0,11)=="meco-endif:"){this.step=d;break;}d++;}if(d>=this.script.length){meco.debuglog("Error in line "+this.step+": if without else/endif");}break;case"meco-call:":this.step=this.step+1;scriptStack.push(this);runningScript=scriptList[c.replace(/meco-call:/,"")];runningScript.go();return null;break;case"meco-endif:":meco.debuglog("endif");break;case"meco-noop:":meco.debuglog("noop");break;default:}}c=c.replace(/%INSTALL_PATH%/gi,mecoVariables.INSTALL_PATH);c=c.replace(/%ROM_PATH%/gi,mecoVariables.ROM_PATH);c=c.replace(/%APP_PATH%/gi,mecoVariables.APP_PATH);c=c.replace(/%PROJECT_NAME%/gi,mecoVariables.PROJECT_NAME);c=c.replace(/%SUPPORT_URL%/gi,mecoVariables.SUPPORT_URL);meco.debuglog("command: "+c);if(c.length>5&&(c.substr(0,5)=="meco:"||c.substr(0,5)=="http:"||c.substr(0,5)=="file:")){meco.debuglog("executing...");location.href=c;}else{this.next(0,c,"",0);}};this.next=function(d,f,e,c){meco.debuglog("--->"+d+" - "+c+": "+this.mecoIf);if(this.mecoIf){this.mecoIf=false;if((d!=0)||(d==0&&c==0)){this.step=this.stepElse;}else{this.step++;}}else{this.step++;}if(this.step<this.script.length){meco.debuglog("<b>next:</b>"+this.step+"/"+this.script.length+"<br/>");this.exec(this.step);}else{this.scriptComplete();}};};function timeout(){meco.debuglog("XXXXX function timeout at line "+runningScript.step+": "+runningScript.script[runningScript.step]);runningScript.exec(runningScript.step);}var mecoError=new Object();mecoError.load=new Object();mecoError.load[0]="load(tag_name, file_name[, encoding=1])";mecoError.load[-10]="Fehlerhafter Parameter";mecoError.load[-11]="Kein InstallPath gesetzt";mecoError.load[-21]="Datei kann nicht gelesen werden";mecoError.load[-22]="Element kann nicht geschrieben werden";mecoError.save=new Object();mecoError.save[0]="save(tag_name, file_name[, encoding=1])";mecoError.save[-10]="Fehlerhafter Parameter";mecoError.save[-11]="Kein InstallPath gesetzt";mecoError.save[-21]="Element kann nicht gelesen werden";mecoError.save[-22]="Speicher f�r Unicode-Konvertierung kann nicht allokiert werden";mecoError.save[-23]="Datei kann nicht geschrieben werden";mecoError.createInstallPath=new Object();mecoError.createInstallPath[0]="createInstallPath(project_name)";mecoError.createInstallPath[-10]="Fehlerhafter Parameter";mecoError.createInstallPath[-20]="Verzeichnis kann nicht erstellt werden";mecoError.createShortcut=new Object();mecoError.createShortcut[0]="createShortcut(folder_name, shortcut_name, command_line)";mecoError.createShortcut[-10]="Fehlerhafter Parameter";mecoError.createShortcut[-20]="Windows-Version kann nicht ermittelt werden";mecoError.createShortcut[-21]="Verzeichnis kann nicht erstellt werden";mecoError.createShortcut[-22]="Verkn�pfung kann nicht erstellt werden";mecoError.copyContent=new Object();mecoError.copyContent[0]="copyContent(source, destination)";mecoError.copyContent[-10]="Fehlerhafter Parameter";mecoError.copyContent[-11]="Kein InstallPath gesetzt";mecoError.copyContent[-20]="Absoluter Pfad als Ziel ist nicht erlaubt";mecoError.copyContent[-30]="Fehler beim Kopieren aufgetreten";mecoError.setFullscreen=new Object();mecoError.setFullscreen[0]="setFullscreen(0|1)";mecoError.setFullscreen[-10]="Fehlerhafter Parameter";mecoError.get=new Object();mecoError.get[0]="get(variable_name)";mecoError.get[-10]="Fehlerhafter Parameter";mecoError.get[-20]="Variable nicht definiert";mecoError.set=new Object();mecoError.set[0]="set(variable_name, value)";mecoError.set[-10]="Fehlerhafter Parameter";mecoError.set[-20]="Variable kann nicht definiert werden";mecoError.set[-21]="System-Variable kann nicht �berschrieben werden";mecoError.showPopup=new Object();mecoError.showPopup[0]="showPopup(0|1)";mecoError.showPopup[-10]="Fehlerhafter Parameter";mecoError.loadPopup=new Object();mecoError.loadPopup[0]="loadPopup(url)";mecoError.loadPopup[-10]="Fehlerhafter Parameter";mecoError.loadPopup[-11]="Kein InstallPath gesetzt";mecoError.saveVariables=new Object();mecoError.saveVariables[0]="saveVariables( include_system_variables=0|1 [, file])";mecoError.saveVariables[-10]="Fehlerhafter Parameter";mecoError.saveVariables[-11]="Kein InstallPath gesetzt";mecoError.saveVariables[-20]="Verzeichnis 'xsl' kann nicht erstellt werden";mecoError.saveVariables[-21]="Datei kann nicht geschrieben werden";mecoError.loadVariables=new Object();mecoError.loadVariables[0]="loadVariables(reset=0|1[,filename])";mecoError.loadVariables[-10]="Fehlerhafter Parameter";mecoError.loadVariables[-11]="Kein InstallPath gesetzt";mecoError.checkROM=new Object();mecoError.checkROM[0]="checkROM(drive/path)";mecoError.checkROM[-10]="Fehlerhafter Parameter";mecoError.checkROM[-20]="Pfad beginnt nicht mit '[A-Z]:'";mecoError.fileExists=new Object();mecoError.fileExists[0]="fileExists(path)";mecoError.fileExists[-10]="Fehlerhafter Parameter";mecoError.fileExists[-11]="Kein InstallPath gesetzt";mecoError.cleanUp=new Object();mecoError.cleanUp[0]="cleanUp(relaive_path)";mecoError.cleanUp[-10]="Fehlerhafter Parameter";mecoError.cleanUp[-11]="Kein InstallPath gesetzt";mecoError.cleanUp[-21]="Pfad existiert nicht";mecoError.createFolder=new Object();mecoError.createFolder[0]="createFolder(relative_path)";mecoError.createFolder[-10]="Fehlerhafter Parameter";mecoError.createFolder[-11]="Kein InstallPath gesetzt";mecoError.createFolder[-20]="Absoluter Pfad als Ziel ist nicht erlaubt";mecoError.createFolder[-30]="Fehler beim Erstellen des Pfades aufgetreten";mecoError.checkKey=new Object();mecoError.checkKey[0]="checkKey(key)";mecoError.checkKey[-10]="Fehlerhafter Parameter";mecoError.checkKey[-11]="ung�ltiger Key";
