UNPKG

cejs

Version:

A JavaScript module framework that is simple to use.

314 lines 18.2 kB
�� /** * @name CeL function for Windows job * @fileoverview * ,g�jHhS+T�N Windows job �v functions0 * @since */ 'use strict'; if (typeof CeL === 'function') CeL.run( { name:'application.OS.Windows.job', require : 'data.code.compatibility.|data.native.', code : function(library_namespace) { /** * null module constructor * @class Windows job �v functions */ var _// JSDT:_module_ = function() { // null module constructor }; /** * for JSDT: g prototype Mbg\KNvu\O Class */ _// JSDT:_module_ .prototype = { }; // gܕ�[݈�v�R function install(dir){//move files: input base dir var f,d,i=0,s=0,c=0,l=getResource("filelist").split(/[\r\n]+/);//.replace(/[\r\n]+/g,"\n").split('\n') for(;i<l.length;i++)if(l[i]&&l[i].charAt(0)!='#'&&(f=l[i].split('\t'))){ d=turnToPath(f[1]),f=f[0],d=d?isFolder(d)?(isFolder(d)==2?dir:'')+d+f:d:dir+f; if(f)if(c++,d=mv(f,d))pErr(d);else s++; else if(d)pLog('�0�0�0�0 '+d+' n0\Ob�0'+(isFolder(d,1)?'b�R':'1YWe')+'W0_0'); } if(c)pLog(s+"/"+c+"filesn0�y�Rk0b�RW0_0"); } function rmProg(){ if(typeof getResource=='undefined')return; var i=0,f,l=getResource("proglist").split(/\r\n/);//.replace(/[\r\n]+/g,"\n").split('\n') for(;i<l.length;i++)if(l[i]&&(f=l[i].split('\t')[0]))try{fso.DeleteFile(f);}catch(e){} } // HQzl�h�N,nf�@.js;N�j �vu�lOUL�Bfreturn 00dk�Qxe�O(u0Rfunction.jsKN(vQ�N)�R���includeeQ� // include:getScriptName(),mergeScript() function preCheck(argumentCount,ver,mFN){ // argumentxe,gNOHr,g,�ver<5.1BfTuO�j T var SN=getScriptName(),WshShell=WScript.CreateObject("WScript.Shell"); if(!argumentCount)argumentCount=0; if(!WScript.Interactive){ WshShell.Popup('This program must run in interactive mode!\ndk z_��WL��e�N�R!j_�',0,SN,48); return 5; } if(WScript.Arguments.length>argumentCount){ if(typeof WScript.Arguments.ShowUsage=='unknown'||WScript.Arguments.ShowUsage)WScript.Arguments.ShowUsage(); else WshShell.Popup('Error arguments!\n_xe/����',0,SN,16); return 6; }//else if(2==WshShell.Popup("dk z_�a(u�e3^�vU�t0",0,"�x�[�WL��",1+64))return 4; // �N N�Sn�e.wsf-N0 if(!ver||ver<5)ver=5;if(!mFN)mFN='process'; if(typeof checkVer=='function')checkVer(ver); // 5.1w�Mb��(u.wsf(windows script file)�c6R else if(WScript.Version>5){WshShell.Popup('ˊ�WL� '+SN+'.wsf �j�',0,SN+': N/f�WL�� P�j�U�',48);return 7;} else if(mergeScript(mFN+'.js')){WshShell.Popup('TuO�jHh1YWe�',0,SN,16);return 8;} else{ try{fso.CopyFile(SN+'.ini',mFN+'.ini');}catch(e){} // copy .ini WshShell.Popup('ˊ-��[}Y '+mFN+'.ini �\nKN�_�`�Sf�f� '+mFN+'.js �j �FO&N NN�[���)R�WL�0',0,SN+': O(u�vHr,gN� ��',48);return 9; } //fso=null; return 0; } /* 2009/6/18 20:46:1 �f�e�R�� update function �S�NVf�\ for_check T(W install_url -N0 */ //Update[generateCode.dLK]='getU,getFN,simpleWrite'; // ,Debug_for_include,gDate function Update(for_check, install_url) { return Update.check(Update.setup(for_check, install_url)); } // base function Update.check=function(force){ if(!this.URL)return; if(force||!this.version){ var d=this.parse(getU(this.URL)||''); this.version_get=d; //sl('Update.check: version get: ['+this.version_get+']'); } return this.version=[this.version_get,this.version_now,this.URL]; }; Update.set_URL=function(for_check,install_url){ var unchang=1; if(for_check){ if(unchang) unchang= this.URL==for_check; //sl('Update.set_URL: -��[�j,n URL: <a href="'+for_check+'">'+for_check+'</a>'); this.URL=for_check; } if(install_url){ if(unchang) unchang= this.download_URL==install_url; //sl('Update.set_URL: -��[ z_ N � URL: <a href="'+install_url+'">'+install_url+'</a>'); this.download_URL=install_url; } return !unchang; }; /* TODO: date �v TBf�k�'Y\ */ Update.up_to_date=function(){ return 0>=this.compare(this.version_now,this.version_get); }; Update.install=function(){ var p=getFN(decodeURI(location.pathname)),t=p+'.new',b=p+'.old',f=this.after_install; //sl('Update.install: program path: ['+p+']'); if(this.download(t)){ try{fso.DeleteFile(b);}catch(e){} try{ fso.MoveFile(p,b); fso.MoveFile(t,p); }catch(e){f&&f(e,p,t);return;} f&&f(); return 1; } }; Update.check_string='check_string'; Update.download=function(to_where){ //sl('Update.download: download [<a href="'+this.download_URL+'">'+this.download_URL+'</a>] to ['+to_where+']'); var data=getU(this.download_URL),f=this.after_download; if(data&&(!this.check_string||data.indexOf(this.check_string)!=-1)){ simpleWrite(to_where,data,TristateTrue); f&&f(0,data); return data; }else f&&f(1,data); }; // default user function Update.setup=function(for_check,install_url){ var v=document.getElementById('version'); if(v)v=v.innerHTML.replace(/[\s\n]+$|^[\s\n]+/g,''); this.version_now=new Date(v||document.lastModified); //sl('Update.setup: version now: ['+this.version_now+']'); return this.set_URL(for_check,install_url); }; Update.parse=function(version_data){ return new Date(version_data||0); }; Update.compare=function(v1,v2){ //sl('Update.compare: ['+v2+'] - ['+v1+'] = '+(v2-v1)); return v2-v1; }; Update.after_install=function(e,prog,tmp){ // e: Error object if(e){error(e);error('Update.install: !q�l�f�c z_�j ['+prog+']0�e�v z_�jn�e ['+tmp+']0');} else sl('�f�e�[bu0'),warn('�`���<b onclick="history.go(0);">͑�e���S</b>�N�[b�f�e�'); }; Update.after_download=function(e,data){ // e: error code if(e)error('Update.download: N � [<a href="'+this.download_URL+'">'+this.download_URL+'</a>] |vu/����'); }; /* ��eQ�UL� item=value KN-��[ !noComment: '#', ';' w�-�0// KN�_�S / *..* / KN��\��weu */ function parseData(s,noComment){ if(!s/*||s.charAt(0)=='#'*/ || !noComment&&!(s=s.replace(/([#;]|\/\/).*$/g,'')))return; // �S�c�UL�;�� var t,c,r,i=1; //alert(s); if(t=s.match(/^\s*\[(.*)\]/)) return t[1]; // R@S try{ // �lT(WNw�/f�p�N(W�NOHr,g-NrKN-��[�S��1YWe r=new RegExp('^\\s*([^=]+)\\s*=\\s*([^\\r\\n]*)'); t=s.match(r); }catch(e){ t=s.match(/^\s*([^=]+)\s*=\s*([^\r\n]*)/); } // O(udk_�S��\��g�NOUL� if(t){//if(t=s.match(/^\s*([^=]+?)\s*=\s*([^\r\n]*)/)){ // �_b��v��SHQ!|ToHr if(!t[1])return; var set=[]; //set[0]=t[1].replace(/\s+$|^\s+/g,''); set[0]=t[1].trim(); t=set[1]=t[2]; while((c=t.charAt(0))=='"'||c=="'"){ //alert('^'+c+'([^'+c+']*)'+c+'[^\'"]*(.*)$'); if(!(c=t.match(new RegExp('^'+c+'([^'+c+']*)'+c+'[^\'"]*(.*)$'))))break; //alert('['+set[0]+']=\n'+t+'\n'+c[1]+'\n['+c[2]+']'); set[i++]=c[1]; t=c[2];//if(c=t.match(/^\s+/))t=t.substr(c.length); //alert('['+t+']'); } return set; } } /* readin .ini file http://en.wikipedia.org/wiki/Ini_file */ //parseINI[generateCode.dLK]='initialization_WScript_Objects,parseData,ForReading,TristateUseDefault'; function parseINI(FN,format,INIunBlock,noComment){ var INI={},datas; // -��[<PKNc�R,*gFhw��-��[@SJX �KN<P if(!INIunBlock)INIunBlock='[unBlock]'; // *gFhw��-��[@SJX �KN<P INI[INIunBlock]={}; try{ datas=fso.OpenTextFile(FN,ForReading,false,format||TristateUseDefault); }catch(e){} // N(uopenTemplate()�vu~b N0Rdk.ini�jBfpass � No�:yerror if(!datas){ //if(!INI)INI=[],INI[block=INIunBlock]=[];return 1; //alert('Cannot open:\n'+FN); return 0; } var i,j,index,k,t,block,inC=false; // index,temp,@SJX,�e;��-N(in comment) //INI=[],INI[block=INIunBlock]=[]; // �k!k�WL�sS͑-� while(!datas.AtEndOfStream)if(t=datas.ReadLine()){ if(!noComment){ t=t.replace(/\/\/.*/,''); // U�t/*..*/MRHQU�t// k=1; while(k){ k=0; // .replace(/\/\*.*?\*\//g,'') (W ver5 MRg�Q�s/��� //if(!inC&&(i=t.indexOf('/*'))!=-1)if((j=t.indexOf('*/',i+2))==-1){inC=true,t=t.slice(0,i);break;}else k=1,t=t.slice(0,i)+t.substr(j+2); if(!inC&&(i=t.indexOf('/*'))!=-1){ // U�t;�� /* j=i+2; do{j=t.indexOf('*/',j);if(t.charAt(j-1)=='\\')j+=2;else break;}while(j!=-1); // �2� 0\*/ 0 if(j==-1){inC=true,t=t.slice(0,i);break;}else k=1,t=t.slice(0,i)+t.substr(j+2); } //if(inC)if((i=t.indexOf('*/'))==-1)t='';else inC=false,t=t.substr(i+2),k=1; if(inC){ // U�t*/ i=0; do{i=t.indexOf('*/',i);if(t.charAt(i-1)=='\\')i+=2;else break;}while(i!=-1); // �2� 0\*/ 0 if(i==-1)t='';else inC=false,t=t.substr(i+2),k=1; } } } //if(!t)continue;alert(t); t=parseData(t,noComment);if(!t)continue; if(typeof t=='string'&&!INI[block=t])INI[block]={}; else if(t.length==2)INI[block][t[0]]=t[1]; else for(i=1,INI[block][t[0]]=[];i<t.length;i++)INI[block][t[0]].push(t[i]);//,alert(block+','+t[0]+','+t[i]) //if(t[0])alert('INI['+block+']['+t[0]+']='+INI[block][t[0]]);else alert('block='+block); } datas.Close(); return INI; } /* Scriptlet.Typelib \a��v-��(u�/fk^�R�`uR�^ Windows s�,gD}�N ��[� N ��/fN.zO�`�}�[�vs�,g�S�N�PCOM \a���#j�]\O�v�e�l �0 http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/hey0221.mspx http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rpc/rpc/guid.asp */ function tempGUID(){ var TypeLib=WScript.CreateObject("Scriptlet.TypeLib"),tGUID; try{tGUID=TypeLib.Guid();} catch(e){return;} finally{TypeLib=null;} // sSO try b catch @SJX-N|vu�P�Vs���_ �b�_ catch @SJX-N�d�Q/��� ��Ng�WL� finallyStatements gQ�v z_�x0finallyStatments �OI�g8l`��WL�0 return tGUID; } return ( _// JSDT:_module_ ); } });