//v0.5.7 - o3/2o16 //- fix for version compare to handle versions without "." //- internal fix for scriptwizards own forum thread url handling //- support for native url property (OnInit.Url since DO v12.0.8b) //v0.5.6 - o1/2o16 //- https url support //v0.5.5 - o7/2o15 //- ConfigHelper updated to v1.2 //- column "enabled" separated, not included in cache anmymore //- fix for basename-preserve not removing *.txt extension //- FILE option defaults to "script addins" now (no need to pass full path anymore) //v0.5.4 - o2/2o15 //- merged with colcache devbranch //- german translations added by kundal //- error fix for unknown language in translator //- colcache fix for expired items //- updating script to package or reverse does not change basename //- new script config items to disable keeping of basenames //- new script config items to disable log output for columns //- self update options (silently updates itself by default) //- log file size limited to 2-3mb //v0.5.2 - o2/2o15 //- major ColumnCache fixes and enhancements //v0.5.1 - o2/2o15 //- merged released v0.4.5 with dev branch v0.5 //v0.5 - 12/2o14 //- multi-language support (en, de) //- ul/li tags filtered to prevent thread-parsing error //- column cache activated by default //- winXP error-dialog fix on initialization //- about-dialog error fix for multiple or no listers present //- fetching enabled-status and dopus id of script packages fixed //- about dialog confirmation texts equalized //- error handling enhancements //- remove wrong utf8/16 bom, when saving out to utf16 //- version string comparison enhanced //v0.4.5 - o2/2o15 //- fix for unescaped ampersand in faq links //- fix for emergency download not working (damn it! o) //v0.4.4 - 01/2o15 //- fix for updated board-software on resource.dopus.com //- fix for script packages not extractable error //v0.4.3 - 11/2o14 //- MD5 hash creation bugfix //- german forum download bugfix //- upload prepared files will be automatically converted to unicode (utf16) //- downloads always treated binary //v0.4.2 - 11/2o14 //- added resource center urls for some commands //- added support for german h&p directory opus forum //- added experimental caching of column data (do not enable for regular use) //v0.4.1 - 11/2o14 //- min version added //- lots of new stuff //todo //- clear cache entry for uploaded/prepared items (modifications are already handled) //- enhance progress dialog handling //- max age to auto remove items on compact() //- columnshash //- optional clear on columnhash mismatch //- support type, sort, group for columns //- item metadata storage //- handle bom removal/encoding conversion in every prepareupload step /////////////////////////////////////////////////////////////////////////////// function OnInit(data){ /////////////////////////////////////////////////////////////////////////// Translator. AddT("en", { "command.scriptwizard.description" : "Helps to maintain, handle and update scripting resources.", "command.scriptabout.description" : "Multifunctional 'about'-dailog for scripting resources.", "script.config.archive.path" : "Folder path where to store archived scripts.", "script.config.log.toconsole" : "Enable output to the script console.", "script.config.log.level" : "Log level, 'normal' is the recommended setting. Use 'trace' or 'dump' for extended troubleshooting.", "script.config.log.tofile" : "Enable output to log file.", "script.config.log.tofile.path" : "Log file path.", "script.config.onstartup.update.sw" : "Settings for automatic updating of scriptwizard.", "update.sw.ask" : "Confirm before updating", "update.sw.silent" : "Silently update", "update.sw.disabled" : "disabled", "script.config.preservename.singlescript": "Keep the name of a local script file when updating.", "script.config.preservename.package": "Keep the name of a local package when updating.", "script.config.preservename.typemismatch": "Keep the name of a local script or package if the update is of a different kind. A script file will keep it's name if the update comes as package e.g.", "script.config.columns.cache.enabled" : "Enable caching of script detail columns.", "script.config.columns.cache.expiration" : "Expiration duration in days for each item in the script detail column data." }). AddT("de", { "command.scriptwizard.description" : "Hilft bei der Verwaltung, Handhabung und dem Aktualisieren von Script-Addins.", "command.scriptabout.description" : "Multifunktioneller 'Über'-Dialog für Script-Addins.", "script.config.archive.path" : "Pfad zur Ablage von archivierten Script-Addins.", "script.config.log.toconsole" : "Log-Ausgaben in der Scriptkonsole aktivieren.", "script.config.log.level" : "Log-Level, 'normal' ist der empfohlene Wert. Benutzen Sie 'trace' oder 'dump' für die Fehlersuche.", "script.config.log.tofile" : "Log-Ausgaben in Datei aktivieren.", "script.config.log.tofile.path" : "Pfad zur Log-Datei.", "script.config.onstartup.update.sw" : "Einstellungen für die automatische Aktualisierung von ScriptWizard.", "update.sw.ask" : "Auf Nachfrage aktualisieren", "update.sw.silent" : "Ohne Nachfrage aktualisieren", "update.sw.disabled" : "deaktiviert", "script.config.preservename.singlescript": "Den Namen der lokalen Scriptdatei bei einer Aktualisierung beibehalten.", "script.config.preservename.package": "Den Namen des lokalen Scriptpaketes bei einer Aktualisierung beibehalten.", "script.config.preservename.typemismatch": "Den Namen einer lokalen Scriptresource auch bei unterschiedlichen Typen beibehalten. Ein Script kann somit bspw. zu einem Scriptpaket mit gleichem Namen aktualisiert werden.", "script.config.columns.cache.enabled": "Caching der ScriptDetail-Spaltenwerte aktivieren.", "script.config.columns.cache.expiration": "Ablaufzeit in Tagen für zwischengespeicherte Spaltenwerte." }); /////////////////////////////////////////////////////////////////////////// var uid = "D4072BDA-B049-4A11-8B40-266E083D6F2D"; var url = "http://resource.dopus.com/viewtopic.php?f=35&t=23179"; if (DOpus.Version.AtLeast("12.0.8")) data.url = "http://resource.dopus.com/viewtopic.php?f=35&t=23179"; data.name = "Command.Generic: ScriptWizard"; data.desc = "Helps to maintain, handle and update scripting resources"; data.desc = t("command.scriptwizard.description"); data.copyright = "tbone"; data.version = "0.5.7"; data.default_enable = true; data.min_version = "11.7.1"; if (DOpus.Version.AtLeast("11.8.2")) data.log_prefix = "SW"; var cmd = data.AddCommand(); cmd.name = "ScriptAbout" cmd.method = "Command_ScriptAbout"; cmd.desc = t("command.scriptabout.description"); cmd.template = "FILE/K,WIN/K"; var cmd = data.AddCommand(); cmd.name = "ScriptWizard" cmd.method = "Command_ScriptWizard"; cmd.desc = data.desc; cmd.template = "ABOUT/S,UPDATE/S,ARCHIVE/S,VISIT/S,OPENLOG/S,ALL/S,FILE/K,FOLDER/K,CHECK/S,FORCE/S,INTERACTIVE/S,SILENT/S,SHOWRESULTS/S,UPDATEOFFER/S,PREPAREUPLOAD/S,UPDATEHASH/S,PROGRESS/S,CLEARCOLS/S,WIN/K"; /////////////////////////////////////////////////////////////////////////// function ConfigHelper(data){ //v1.2 var th=this; th.d=data; th.c=data.config; th.cd=DOpus.Create.Map(); th.add=function(name, val, des){ th.l={n:name,ln:name. toLowerCase()}; return th.val(val).des(des);} th.des=function(des){ if (!des) return th; if (th.cd.empty) th.d.config_desc=th.cd; th.cd(th.l.n)=des; return th;} th.val=function(val){ var l=th.l; if (l.v!==l.x&&typeof l.v=="object") l.v.push_back(val);else l.v=th.c[l.n]=val;return th;} th.trn=function(){ return th.des( t("script.config."+th.l.ln));}} /////////////////////////////////////////////////////////////////////////// var cfg = new ConfigHelper(data); cfg.add("Archive.Path", "/dopusdata\\Script Addins\\archive").trn(); cfg.add("Log.ToConsole", true).trn(); cfg.add("Log.Level", DOpus.Create.Vector()).trn(). val(4).val("Exceptions").val("Errors").val("Warning").val("Info").val("Normal").val("Trace").val("Dump"); cfg.add("Log.ToFile", true).trn(); cfg.add("Log.ToFile.Path", "/dopusdata\\logs\\ScriptWizard.log.txt").trn(); cfg.add("Log.What.Columns", false).trn(); cfg.add("Log.What.KeepTmpFiles", false).trn(); cfg.add("Log.What.Other", true).trn(); cfg.add("Columns.Cache.Enabled", true).trn(); cfg.add("Columns.Cache.Expiration", 14).trn(); cfg.add("PreserveName.SingleScript", true).trn(); cfg.add("PreserveName.Package", true).trn(); cfg.add("PreserveName.TypeMismatch", true).trn(); cfg.add("OnStartup.Update.SW", DOpus.Create.Vector()).trn(). val(0).val(t("update.sw.ask")).val(t("update.sw.silent")).val(t("update.sw.disabled")); RemoveDeprecatedVersions(); out.mute(false).level(6); new ColumnCache("ScriptDetails", false).Compact(); } /////////////////////////////////////////////////////////////////////////////// var COMMAND_ABORTED = true; var COMMAND_SUCCEEDED = false; new Translator(this); var FSMagic = new FSMagic(); var ResParser = new DOResourceParser(); /////////////////////////////////////////////////////////////////////////////// Date.prototype.formatTime = function (){ var hour = this.getHours(); if (hour<10) hour="0"+hour; var min = this.getMinutes(); if (min<10) min="0"+min; var secs = this.getSeconds(); if (secs<10) secs="0"+secs; return hour+":"+min+":"+secs; } /////////////////////////////////////////////////////////////////////////////// Date.prototype.formatDate = function (){ var day = this.getDate(); if (day<10) day="0"+day; var month = this.getMonth()+1; if (month<10) month="0"+month; var year = this.getFullYear(); return year+"."+month+"."+day; } /////////////////////////////////////////////////////////////////////////////// String.prototype.lTrim = function(chr){chr=chr||"\\s";return new String(this.replace(new RegExp("^"+chr+"*","i"),''));} String.prototype.rTrim = function(chr){chr=chr||"\\s";return new String(this.replace(new RegExp(chr+"*$","i"),''));} String.prototype.trim = function(chr){return this.lTrim(chr).rTrim(chr);} String.prototype.left = function(chrs){return this.substring(0,chrs);} String.prototype.right = function(chrs){return this.substring(this.length-chrs);} /////////////////////////////////////////////////////////////////////////////// try { var out = new DebugOutput(); if (Script); //will fail here on script (re)load once out.level(Script.Config["Log.Level"]). console(Script.Config["Log.ToConsole"]). buffer(true); //out._keepInds = true; if (Script.Config["Log.ToFile"] && Script.Config["Log.ToFile.Path"]) out.max(1024*1024*2). tolerance(50). append(DOpus.FSUtil.Resolve(Script.Config["Log.ToFile.Path"])); var ColCache = new ColumnCache("ScriptDetails", /* enabled */ Script.Config["Columns.Cache.Enabled"], /* expire after */ Script.Config["Columns.Cache.Expiration"]*86400000 /*(ms of a day)*/, /* persistent */ true, /* column names */ ["Name","Description","Copyright","Enabled","Version","MinVersion","Status","Modified","Url","Info"]); ColCache.log = Script.Config["Log.What.Columns"]; out.mute(); } catch(e){ DOpus.Output("Loaded successfully."); //throw e; } var gThis = this; /////////////////////////////////////////////////////////////////////////////// function Command_ScriptAbout(data){ //deprecated, do not use! out.mute(false); data.func.command.ClearFiles(); out.trc("ScriptAbout():",1); var p = { file : GetParameter(data, "FILE", null, ""), win : GetParameter(data, "WIN", null, "") } var ad = new AboutDialog( p.file, p.win); ad.Init(); ad.Show(); out.reset(); } /////////////////////////////////////////////////////////////////////////////// function Command_ScriptWizard(data){ out.mute(false); out.trc("ScriptWizard():",1); data.func.command.ClearFiles(); var result = COMMAND_SUCCEEDED; var p = { about : GetParameter(data, "ABOUT", null, false), update : GetParameter(data, "UPDATE", null, false), archive : GetParameter(data, "ARCHIVE", null, false), visit : GetParameter(data, "VISIT", null, false), openLog : GetParameter(data, "OPENLOG", null, false), all : GetParameter(data, "ALL", null, false), file : GetParameter(data, "FILE", null, ""), folder : GetParameter(data, "FOLDER", null, ""), check : GetParameter(data, "CHECK", null, false), updateOffer : GetParameter(data, "UPDATEOFFER", null, false), updateHash : GetParameter(data, "UPDATEHASH", null, false), prepScript : GetParameter(data, "PREPAREUPLOAD", null, false), force : GetParameter(data, "FORCE", null, false), interactive : GetParameter(data, "INTERACTIVE", null, false), silent : GetParameter(data, "SILENT", null, false), showResults : GetParameter(data, "SHOWRESULTS", null, false), progress : GetParameter(data, "PROGRESS", null, false), clearCols : GetParameter(data, "CLEARCOLS", null, false), win : GetParameter(data, "WIN", null, null) } if (!p.win) p.win = data.func.sourcetab.lister; var resUp = new DOResourceUpdater(); resUp.silent = p.silent; resUp.interactive = p.interactive; resUp.progress = p.progress; resUp.showResults = p.showResults; resUp.win = p.win; resUp.force = p.force; resUp.updateOffer = p.updateOffer function GetFiles(data){ try{ var files = data.func.sourcetab.selected_files; return { enumerator:new Enumerator(files), count:files.count}; } catch(e){ return {enumerator:null, count:0}; } } var resultTmp = true; var files = {enumerator:null, count:0}; if (!p.folder) p.folder = DOpus.FSUtil.Resolve("/dopusdata/script addins"); var file = ""; if (p.file) file = p.file; else { files = GetFiles(data); if (files.count) file = files.enumerator.item().realpath; } /////////////////////////////////////////////////////// if (0){} else if (p.about && file){ var ad = new AboutDialog( file, p.win); ad.Init(); ad.Show(); } /////////////////////////////////////////////////////// else if (p.visit && file){ resultTmp = resUp.Visit(file); } /////////////////////////////////////////////////////// else if (p.clearCols){ resultTmp = ColCache.Clear(); } /////////////////////////////////////////////////////// else if (p.archive){ out.put("Archive.."); if (p.file) resultTmp = resUp.ArchiveScript(String(p.file)); else if (p.all){ var fEnum = new Enumerator(data.func.sourcetab.files); while (!fEnum.atEnd()) { var file = fEnum.item().realpath; fEnum.moveNext(); resUp.ArchiveScript(String(file)); } } else if (files.count){ var fEnum = files.enumerator; while (!fEnum.atEnd()) { var file = fEnum.item().realpath; fEnum.moveNext(); resUp.ArchiveScript(String(file)); } } else out.put("Bad params. No scripts given/selected."); } /////////////////////////////////////////////////////// else if (p.openLog){ out.put("OpenLog.."); resultTmp = !resUp.OpenLog(); } /////////////////////////////////////////////////////// else if (p.check){ out.put("Check.."); if (p.all) resultTmp = resUp.UpdateCheckAll(p.folder); else if (p.file) resultTmp = resUp.UpdateCheck(p.file); else if (files.count){ var fEnum = files.enumerator; while (!fEnum.atEnd()) { var file = fEnum.item().realpath; fEnum.moveNext(); resUp.UpdateCheck(file); } } else out.put("Bad params. No scripts given/selected."); } /////////////////////////////////////////////////////// else if (p.update){ out.put("Update.."); if (p.all) resultTmp = resUp.UpdateAll(p.folder); else if (p.file) resultTmp = resUp.Update(p.file); else if (files.count){ var fEnum = files.enumerator; while (!fEnum.atEnd()) { var file = fEnum.item().realpath; fEnum.moveNext(); resultTmp = resUp.Update(file); } } else out.put("Bad params. No scripts given/selected."); } /////////////////////////////////////////////////////// else if (p.updateHash && file){ out.put("UpdateHash.."); var preparer = new UploadPreparer(); resultTmp = preparer.UpdateMD5(file); } /////////////////////////////////////////////////////// else if (p.prepScript && file){ out.put("PrepScript.."); var preparer = new UploadPreparer(); preparer.win = p.win; resultTmp = preparer.PrepareScript(file); } /////////////////////////////////////////////////////// else { out.put("Bad params. Bad command or no script given/selected."); result = COMMAND_ABORTED; } if (!resultTmp) result = COMMAND_ABORTED; out.reset(); return result; } /////////////////////////////////////////////////////////////////////////////// function OnAboutScript(data){ //v0.1 var cmd = DOpus.Create.Command(); if (!cmd.Commandlist('s').exists("ScriptWizard")){ if (DOpus.Dlg.Request("The 'ScriptWizard' add-in has not been found.\n\n"+ "Install 'ScriptWizard' from [resource.dopus.com].\nThe add-in enables this dialog and also offers "+ "easy updating of scripts and many more.","Yes, take me there!|Cancel", "No About.. ", data.window)) cmd.RunCommand('http://resource.dopus.com/viewtopic.php?f=35&t=23179');} else cmd.RunCommand('ScriptWizard ABOUT WIN='+data.window+' FILE="'+Script.File+'"'); } /////////////////////////////////////////////////////////////////////////////// function OnStartup(){ var cmd = DOpus.Create.Command(); if (Script.config["OnStartup.Update.SW"] == 2) //updating sw disabled return; if (Script.config["OnStartup.Update.SW"] == 1){ //updating sw silently DOpus.Delay(15000); cmd.RunCommand('ScriptWizard UPDATE FILE="'+Script.File+'"'); } if (Script.config["OnStartup.Update.SW"] == 0){ //updating sw with confirmation DOpus.Delay(15000); cmd.RunCommand('ScriptWizard CHECK INTERACTIVE UPDATEOFFER PROGRESS FILE="'+Script.File+'"'); } } /////////////////////////////////////////////////////////////////////////////// function AboutDialog( file, win){ this.res = null; this.file = file; this.win = win; this.cmd = DOpus.Create.Command(); this.confirm = 1; /////////////////////////////////////////////////////////////////////////// this.Show = function(){ out.trc("ShowAbout():",1); var dlg = DOpus.Dlg; dlg.window = (this.win?this.win:null); dlg.message = this.GetText(); dlg.title = "ScriptAbout: "+this.res.name; dlg.buttons = this.buttons; dlg.icon = "info"; dlg.max = 512; dlg["default"] = this.file; var label = t("req.confirm_operations"); for(var len=0;len<120;len++) label+=" ";label+="\t"; dlg.options(0).label = label; dlg.options(0).state = this.confirm; var result = dlg.Show(); this.confirm = dlg.options(0).state; switch (result){ case this.BtnID(t("button.visitforum")): this.Button_VisitForum(); break; case this.BtnID(t("button.checkversion")): this.Button_UpdateCheck(); break; case this.BtnID(t("button.update")): this.Button_Update(); break; case this.BtnID(t("button.updateall")): this.Button_UpdateAll(); break; case this.BtnID(t("button.openlog")): this.Button_OpenLog(); break; case this.BtnID(t("button.showdetails")): this.Button_ShowDetails(); break; case this.BtnID(t("button.prepareupload")): this.Button_PrepareUpload(); break; case this.BtnID(t("button.archive")): this.Button_Archive(); break; case this.BtnID(t("button.updatemd5")): this.Button_UpdateMD5(); break; case this.BtnID(t("button.delete")): this.Button_Delete(); break; case this.BtnID(t("button.rename")): this.Button_Rename(dlg.input); break; case this.BtnID(t("button.exit")): break; } out.trc("",-1); return COMMAND_SUCCEEDED; } /////////////////////////////////////////////////////////////////////////// this.Button_VisitForum = function(){ this.cmd.RunCommand('ScriptWizard VISIT INTERACTIVE FILE="'+this.file+'" WIN='+this.win); this.Show(); } /////////////////////////////////////////////////////////////////////////// this.Button_Rename = function(newFileNamePath){ var doPath = DOpus.FSUtil.NewPath(this.file); var newName = newFileNamePath.getFilePart(); var newNamePath = doPath.pathpart+"\\"+newName; if (this.confirm && !Request(t("req.rename.text", this.res.name, this.res.filePath.getFilePart()), t("button.ok | button.cancel"), t("req.rename.title"), "question", this.win)){ } else { if (!newName || DOpus.FSUtil.Exists(newNamePath)){ Request(t("req.rename_err.text"), t("button.ok"), t("req.rename_err.title"), "error", this.win); } else { this.cmd.RunCommand('Rename FROM="'+this.file+'" TO="'+newName+'"'); this.file = newNamePath; this.Init(); } } this.Show(); } /////////////////////////////////////////////////////////////////////////// this.Button_Delete = function(){ if (!Request(t("req.delete.text", this.res.name, this.res.filePath.getFilePart()), t("button.ok|button.cancel") ,t("req.delete.title"),"question",this.win)){ this.Show(); } else this.cmd.RunCommand('Delete QUIET FORCE FILE="'+this.file+'"'); } /////////////////////////////////////////////////////////////////////////// this.Button_UpdateCheck = function(){ this.cmd.RunCommand('ScriptWizard CHECK UPDATEOFFER INTERACTIVE PROGRESS WIN='+ this.win+' FILE="'+this.file+'"'); this.Show(); } /////////////////////////////////////////////////////////////////////////// this.Button_Update = function(){ if (this.confirm && !Request( t("req.update.text", this.res.name, this.res.filePath.getFilePart()), t("button.ok|button.cancel"), t("req.update.title"), "question", this.win)){ } else{ this.cmd.RunCommand('ScriptWizard UPDATE INTERACTIVE PROGRESS WIN='+this.win+' FILE="'+this.file+'"'); this.Init(); //reload script } this.Show(); } /////////////////////////////////////////////////////////////////////////// this.Button_UpdateAll = function(){ if (this.confirm && !Request( t("req.update_all.text"), t("button.ok|button.cancel"), t("req.update_all.title"), "question", this.win)){ } else this.cmd.RunCommand('ScriptWizard UPDATE ALL PROGRESS SHOWRESULTS WIN='+this.win); this.Show(); } /////////////////////////////////////////////////////////////////////////// this.Button_OpenLog = function(){ this.cmd.RunCommand('ScriptWizard OPENLOG'); this.Show(); } /////////////////////////////////////////////////////////////////////////// this.Button_ShowDetails = function(){ var details = ""; for(prop in this.res){ if (prop.substring(0,1)=="_") continue; details += prop.toUpperCase()+":\n "+this.res[prop]+"\n"; } Request(details,t("button.ok"),t("req.details.title"),"info",this.win); this.Show(); } /////////////////////////////////////////////////////////////////////////// this.Button_Archive = function(){ if (!this.cmd.RunCommand('ScriptWizard ARCHIVE FILE="'+this.file+'"')) Request( t("req.archive_err.text", this.res.name, this.res.filePath.getFilePart()), t("button.ok"), t("req.archive_err.title"), "error", this.win); else Request( t("req.archive_succeeded.text", this.res.name), t("button.ok"), t("req.archive_succeeded.title"), "info", this.win); this.Show(); } /////////////////////////////////////////////////////////////////////////// this.Button_UpdateMD5 = function(){ if (this.confirm && !Request( t("req.updatemd5.text", this.res.name, this.res.filePath.getFilePart()), t("button.ok | button.cancel"), t("req.updatemd5.title"), "question", this.win)){ } else { if (!this.cmd.RunCommand('ScriptWizard UPDATEHASH FILE="'+this.file+'"')) Request( t("req.updatemd5_err.text", this.res.name), t("button.ok"),t("req.updatemd5_err.title"),"error",this.win); else Request( t("req.updatemd5_succeeded.text", this.res.name), t("button.ok"), t("req.updatemd5.title"), "info", this.win); } this.Show(); } /////////////////////////////////////////////////////////////////////////// this.Button_PrepareUpload = function(){ if (!this.cmd.RunCommand('ScriptWizard PREPAREUPLOAD FILE="'+this.file+'" WIN='+this.win)) Request( t("req.prepare_err.text",this.res.name), t("button.ok"), t("req.prepare_err.title"), "error", this.win); else Request( t("req.prepare_succeeded.text",this.res.name), t("button.ok"), t("req.prepare_succeeded.title"),"info",this.win); this.Show(); } /////////////////////////////////////////////////////////////////////////// this.GetText = function(){ var text = ""; text += t("words.name")+":\n "+this.res.name; if (this.res.uid) text+=" - (id: "+this.res.uid+")"; if (this.res.desc) text+="\n\n"+t("words.description")+":\n "+this.res.desc; //if (props.copyright) text+="\n\nCopyright:\n "+this.res.copyright; if (this.res.version) text+="\n\n"+t("words.version")+", "+t("words.modified")+":\n "+this.res.version+", "; if (this.res.modified===null) text +=t("words.modified_unknown"); else text+=(this.res.modified?t("words.modified_yes"):t("words.modified_no")); //if (this.res.min_version) text+="\n\nMinVersion:\n "+props.min_version; text+="\n\n"+t("words.resourceurl")+":\n "+(this.res.url?this.res.url:t("words.unavailable")); return text; } /////////////////////////////////////////////////////////////////////////// this.BtnID = function(label){ for(var b=0;b", // "init.failed.title" : "AboutDialog - Error", "init.failed.text" : "Loading script [%s] failed." }). AddT("de", { "button.ok" : "Ok", "button.cancel" : "Abbruch", // "button.visitforum" : "Forum besuchen", "button.checkversion" : "Version prüfen", "button.update" : "Aktualisieren", "button.updateall" : "Aktualisieren (alle)", "button.openlog" : "Log-Datei öffnen", "button.prepareupload" : "Upload vorbereiten", "button.updatemd5" : "MD5 aktualisieren", "button.showdetails" : "Details anzeigen", "button.archive" : "Archivieren", "button.rename" : "Umbenennen", "button.delete" : "Löschen", "button.exit" : "Beenden", // "req.confirm_operations" : "Bestätigung für Aktionen anfordern", // "req.delete.title" : "Skript löschen", "req.delete.text" : "Das folgende Skript wirklich löschen?\n\nName:\n %s\nDatei:\n %s", // "req.rename.title" : "Skript umbenennen", "req.rename.text" : "Dieses Skript wirklich umbenennen?\n\nSkriptname:\n %s\nDateiname:\n %s", "req.rename_err.title" : "Skript umbenennen - Fehler", "req.rename_err.text" : "Umbenennen fehlgeschlagen!\n\nEs wurde kein gültiger Name gegeben oder die Datei existiert bereits.", // "req.update.title" : "Skript aktualisieren", "req.update.text" : "Dieses Skript wirklich aktualisieren?\n\nSkriptname:\n %s\nDateiname:\n %s", // "req.update_all.title" : "Skripte aktualisieren", "req.update_all.text" : "Du bist dabei, alle Skripte zu aktualisieren.\n\n"+ "Keine Sorge, der Vorgang ist sicher! Skripte, die von dir geändert oder modifiziert wurden, "+ "werden nicht automatisch aktualisiert.\nAlle Skript-Konfigurationen bleiben erhalten.", // "req.details.title" : "Skript-Details", // "req.archive_succeeded.title" : "Skript archivieren", "req.archive_succeeded.text" : "Archivierung des Skripts [%s] erfolgreich!", "req.archive_err.title" : "Skript archivieren - Fehler", "req.archive_err.text" : "Archivierung des Skripts [%s] fehlgeschlagen!", // "req.updatemd5.title" : "Hash aktualisieren", "req.updatemd5.text" : "Den MD5 Hash dieses Skripts wirklich aktualisieren?\n\nSkriptname:\n %s\nDateiname:\n %s", "req.updatemd5_succeeded.text" : "Aktualisierung des MD5 Hashwertes des Skripts [%s] erfolgreich!", "req.updatemd5_err.title" : "Skript archivieren - Fehler", "req.updatemd5_err.text" : "Die Aktualisierung des MD5 Hashwertes des Skripts [%s] ist fehlgeschlagen!", // "req.prepare_succeeded.title" : "Skript zum Upload vorbereiten", "req.prepare_succeeded.text" : "Vorbereitung des Skripts zum Upload [%s] erfolgreich!", "req.prepare_err.title" : "Skript zum Upload vorbereiten - Fehler", "req.prepare_err.text" : "Die Vorbereitung des Skripts zum Upload [%s] ist fehlgeschlagen!", // "words.name" : "Name", "words.description" : "Beschreibung", "words.version" : "Version", "words.resourceurl" : "Url der Ressource", "words.modified" : "modifiziert", "words.modified_yes" : "*** modifiziert ***", "words.modified_no" : "nicht modifiziert", "words.modified_unknown" : "unbekannt", "words.unavailable" : "", // "init.failed.title" : "Info-Dialog - Fehler", "init.failed.text" : "Das Laden des Skripts [%s] ist fehlgeschlagen." }); /////////////////////////////////////////////////////////////////////////// this.buttons = t("button.visitforum |"+ "button.checkversion + button.update + button.updateall + button.openlog |"+ "button.prepareupload + button.updatemd5 + button.showdetails |"+ "button.archive + button.rename + button.delete |"+ "button.exit"); this.abuttons = this.buttons.replace(/\+/g,"|").split("|"); } /////////////////////////////////////////////////////////////////////////////// var RES_UPDATE_FOUND = 1; var RES_UPDATED = 2; var RES_UPTODATE = 4; var RES_UPDATE_UNSUPPORTED = 8; var RES_STATUS_FAILED = 16; var RES_UPDATE_FAILED = 32; var RES_UNKNOWN = 1024; var RES_MORERECENT = 2048; var RES_MODIFIED = 4096; var ERR_RES_NORESURL = 110; var ERR_RES_NOVERSION = 120; var ERR_RES_NOVERSIONS = 130; var ERR_RES_NOVERSIONDOWN = 140; var ERR_FILE_NOT_FOUND = 210; var ERR_BAD_FILETYPE = 215; var ERR_BAD_XMLRESPONSE = 220; var ERR_BAD_HTTPSTATUS = 230; var ERR_BAD_XMLHTTP = 240; var ERR_UID_MISMATCH = 250; var ERR_MISSING_ARCFILE = 260; var ERRMSGS = []; ERRMSGS[ERR_RES_NORESURL] = "Missing resource url in script"; ERRMSGS[ERR_RES_NOVERSION] = "Missing version information in script"; ERRMSGS[ERR_RES_NOVERSIONS] = "No downloads found for script"; ERRMSGS[ERR_RES_NOVERSIONDOWN] = "No version string in download details"; ERRMSGS[RES_MORERECENT] = "The local script is more recent"; ERRMSGS[RES_MODIFIED] = "The local script has been modified"; ERRMSGS[ERR_FILE_NOT_FOUND] = "Script file not found"; ERRMSGS[ERR_BAD_FILETYPE] = "Unsupported file/script-type"; ERRMSGS[ERR_BAD_XMLRESPONSE] = "Resource parsing error"; ERRMSGS[ERR_BAD_HTTPSTATUS] = "Downloading resource failed"; ERRMSGS[ERR_BAD_XMLHTTP] = "No XMLHttp object available"; ERRMSGS[ERR_UID_MISMATCH] = "Unique script id mismatch"; /////////////////////////////////////////////////////////////////////////////// function DOResourceUpdater(){ this.fso = new ActiveXObject("Scripting.FileSystemObject"); this.interactive = false; this.showResults = false; this.force = false; this.win = null; this.progress = null; /////////////////////////////////////////////////////////////////////////////// this.OpenProgressDialog = function ( win, title, numFiles){ var progress = DOpus.Create.Command.Progress; progress.delay = false; progress.abort = false; progress.owned = true; progress.full = true; //progress.bytes = true; progress.Init(win); progress.SetTitle(title); progress.Show(); progress.AddFiles(numFiles); return progress; } /////////////////////////////////////////////////////////////////////////// this.OpenLog = function(){ out.trc("OpenLog():",1); var cmd = DOpus.Create.Command(); var logFile = DOpus.FSUtil.Resolve(Script.config["Log.ToFile.Path"]); out.put("Opening file ["+logFile+"]"); if (!DOpus.FSUtil.Exists(logFile)){ out.err("File not found"); out.trc("",-1); if (this.interactive) Request("The log file ["+logFile+"] is missing!", t("button.ok"),"Open Log - Error","error",this.win); return false; } cmd.RunCommand(logFile); out.trc("",-1); return true; } /////////////////////////////////////////////////////////////////////////// this.Visit = function( scriptFile ){ out.trc("Visit():",1); out.put("File: " + scriptFile); var cmd = DOpus.Create.Command(); var res = ResParser.Load(String(scriptFile)) //todo result check / exception out.put("Url: " + res.url); if (res.url.search("https?://")==-1){ out.err("Script has no url set"); if (this.interactive) Request(t("req.visit_forum_err.text"),t("button.ok"),t("req.visit_forum_err.title"),"error",this.win); out.trc("",-1); return false; } out.put("Opening url ["+res.url+"]"); cmd.RunCommand(res.url); out.trc("",-1); return true; } /////////////////////////////////////////////////////////////////////////// this.UpdateCheck = function(resFilePath, showProgress){ var resFileName = String(resFilePath).getFilePart() out.put("UpdateCheck(): \""+resFileName+"\":",1); try{ if (showProgress == undefined) showProgress = this.progress; if (this.progress && showProgress){ this.progress = this.OpenProgressDialog(this.win, "UpdateCheck", 1); //this.progress && this.progress.SetPercentProgress(33); } //progress.SetTitle("MyStatus!"); var status = this.GetStatus(resFilePath, this.interactive, this.updateOption); if (this.progress && showProgress){ //this.progress && this.progress.StepFiles(1); this.progress && this.progress.Hide(); } out.put("",-1); return status; } catch(e){ out.put(e,-1); throw e; } } /////////////////////////////////////////////////////////////////////////// this.Update = function(resFilePath, showProgress){ var resFileName = String(resFilePath).getFilePart(); out.put("Update(): \""+resFileName+"\":",1); if (showProgress == undefined) showProgress = this.progress; if (this.progress && showProgress){ this.progress = this.OpenProgressDialog(this.win, "Update", 1); } try{ //non-interactive, no-update btn var status = this.GetStatus(resFilePath, false, false); if (status.error || !status.update){ if (this.interactive){ this.progress && this.progress.SetStatus(t("progress.title")); Request(t("req.update_err.text",resFileName,status.msg),t("button.ok"),t("req.update_err.title"),"error",this.win); } if (this.progress && showProgress){ //this.progress && this.progress.StepFiles(1); this.progress && this.progress.Hide(); } out.put("",-1); return status; } var proceed = true; if (status.code & RES_MODIFIED) { proceed = false; if (this.force) proceed = true; if (!proceed && this.interactive){ this.progress && this.progress.SetStatus(t("progress.title")); if (Request(t("req.update_confirm.text", resFileName, status.raw.curRes.version, status.raw.versions[0].version), t("req.update_confirm.yes|button.cancel"), t("req.update_confirm.title"),"question",this.win)) proceed = true; } out.put("Update confirmed/forced: "+proceed); } if (proceed) this.ReplaceWithDownload( status.raw.curRes, status.raw.versions[0] ); if (this.progress && showProgress){ //this.progress && this.progress.StepFiles(1); this.progress && this.progress.Hide(); } out.put("",-1); return status; } catch(e){ out.xit("Update(): " + e.message); if (this.interactive) Request(t("req.update_failure.text",e.message),t("button.ok"),t("req.update_err.title"),"error",this.win); out.put("",-1); throw e; } } /////////////////////////////////////////////////////////////////////////// this.ArchiveScript = function(script, throwEx){ out.put("ArchiveScript():",1); out.dmp("TypeIn : " + typeof script); if (throwEx==undefined) throwEx = false; try{ if (typeof script == "string"){ out.dmp("Turning string into resource-object.."); script = ResParser.Load(script) //todo result check / exception } var arcFileName = script.fileName; if (script.version)arcFileName += '_v'+script.version arcFileName += '_'+ new Date().formatDate().replace(/\./g,''); arcFileName += '_'+ new Date().formatTime().replace(/\:/g,''); if (ResParser.IsPackage(script.fileName)) arcFileName += ".osp"; else arcFileName += ".txt"; var arcFolderPath = DOpus.FSUtil.Resolve(Script.config["Archive.Path"]); var arcFilePath = arcFolderPath+"\\"+arcFileName; FSMagic.CreatePath(arcFolderPath); out.put("Source file: " + script.filePath); out.put("Archive file: " + arcFilePath); this.fso.CopyFile(script.filePath, arcFilePath); if (!this.fso.FileExists(arcFilePath)){ out.xit("Archived file is missing, archiving failed"); out.put("",-1); if (throwEx) throw new Error(ERR_MISSING_ARCFILE, ERRMSGS[ERR_MISSING_ARCFILE]); return false; } out.put("",-1); return true; } catch(e){ out.err(e); out.put("",-1); if (throwEx) throw e; } } /////////////////////////////////////////////////////////////////////////// this.ReplaceWithDownload = function(curResource, version){ out.trc("ReplaceWithDownload():",1); this.progress && this.progress.SetStatus("Downloading update.."); try{ var tmpFile = FSMagic.GetTmpFileName("DO.ScriptDownload.", "."+version.extension); this.DownloadToFile(version.url, tmpFile.fullname, true); //version.package); var newScript = ResParser.Load(tmpFile.fullname); out.put("Current script UID: " + curResource.uid); out.put("Update script UID: " + newScript.uid); if (curResource.uid && (newScript.uid != curResource.uid)) throw new Error(ERR_UID_MISMATCH,ERRMSGS[ERR_UID_MISMATCH]); this.ArchiveScript(curResource, true); //throw var newFilePath = curResource.filePath.getParentPart(); var newFileName = version.fileName; if (curResource.package == version.package){ //same type? out.put("Same type of script resource"); if (!curResource.package && Script.Config["PreserveName.SingleScript"]) newFileName = curResource.fileName.rTrim(".txt").getBaseName()+"."+version.extension; //use old script basename if (curResource.package && Script.Config["PreserveName.Package"]) newFileName = curResource.fileName; //use old package basename } else { out.put("Different types of script resources, basename: " + curResource.fileName.replace("\\.txt$","").getBaseName()); if (Script.Config["PreserveName.TypeMismatch"]) //use old resource name if script vs. package? newFileName = curResource.fileName.rTrim(".txt").getBaseName()+"."+version.extension; //use old basename } newFilePath += "\\"+newFileName; out.put("Tmp resource file: " + tmpFile.fullname); out.put("New resource file: " + newFilePath); this.fso.DeleteFile(curResource.filePath); this.fso.MoveFile(tmpFile.fullname, newFilePath); out.inf("Update successful"); if (this.interactive){ Request(t("req.update_success.text" ),t("button.ok"),t("req.update_success.title"),"info",this.win); } out.trc("",-1); } catch(e){ out.xit("ReplaceWithDownload(): " + e.message); out.trc("",-1); throw e; } } /////////////////////////////////////////////////////////////////////////// this.GetStatus = function(resFilePath, interactive, updateOption){ out.trc("GetStatus():",1); var resFileName = String(resFilePath).getFilePart(); this.progress && this.progress.SetName(resFileName); this.progress && this.progress.SetStatus("Analyzing local script file.."); this.progress && this.progress.SetFileSize(100); this.progress && this.progress.StepBytes(0); if (interactive == undefined) interactive=this.interactive; if (updateOption == undefined) updateOption=this.updateOption; var statusRaw = null; var status = {code:RES_UNKNOWN, raw:statusRaw, error:null, update:false, msg:""}; var msg = "", tmpMsg=""; try{ statusRaw = this.GetStatusRaw(resFilePath); this.progress && this.progress.StepBytes(30); status.raw = statusRaw; status.code = statusRaw.code; if (status.code & RES_UPDATE_FOUND && !(status.code & RES_MORERECENT) && !(status.code & RES_UPTODATE)){ status.update = true; (tmpMsg=t("reg.status.updatefound",statusRaw.versions[0].version)) && out.inf(tmpMsg) && (msg+=" "+tmpMsg+"\n"); } else (tmpMsg=t("reg.status.updatenotfound")) && out.put(tmpMsg) && (msg+=" "+tmpMsg+"\n"); if (status.code & RES_UPTODATE) (tmpMsg=t("reg.status.isuptodate")) && out.put(tmpMsg) && (msg+=" "+tmpMsg+"!\n"); if (status.code & RES_MORERECENT) (tmpMsg=t("reg.status.ismorerecent")) && out.wrn(tmpMsg) && (msg+=t("req.status.part.warning", tmpMsg)); if (status.code & RES_MODIFIED) (tmpMsg=t("reg.status.ismodified")) && out.wrn(tmpMsg) && (msg+=t("req.status.part.warning", tmpMsg)); if (interactive){ this.progress && this.progress.StepBytes(60); this.progress && this.progress.SetStatus(t("progress.title")); this.progress && this.progress.Hide(); msg=t("req.status.part.upper", resFileName, status.raw.curRes.version, msg); var updateNow = Request(msg,(this.updateOffer&&status.update?t("button.updatenow | button.cancel"):t("button.ok")),t("req.status.title"),"info",this.win); if (updateNow && this.updateOffer && status.update){ msg = ""; this.progress && this.progress.Show(); this.progress && this.progress.StepBytes(70); this.ReplaceWithDownload( status.raw.curRes, status.raw.versions[0]); } } status.msg = msg; out.trc("",-1); return status; } catch(e){ status.raw = statusRaw; status.error = e; if (e.number>200){ (tmpMsg="Failure: "+e.message) && out.err(tmpMsg) && (msg+=tmpMsg+"!\n"); status.code = RES_STATUS_FAILED; } else if (e.number>100){ (tmpMsg="Unsupported: "+e.message) && out.err(tmpMsg) && (msg+=tmpMsg+"!\n"); //DOpus.Output("UNsupported message:" +e.message); status.code = RES_UPDATE_UNSUPPORTED; } else{ (tmpMsg="Unknown error: "+e.message) && out.err(tmpMsg) && (msg+=tmpMsg+"!\n"); throw e; } status.msg = msg; if (interactive){ this.progress && this.progress.SetStatus(t("progress.title")); msg=t("req.status_err.part.upper", resFileName, msg); Request(msg,t("button.ok"),t("req.status_err.title"),"error",this.win); } out.trc("",-1); return status; } } /////////////////////////////////////////////////////////////////////////// this.GetStatusRaw = function( resFilePath ){ out.trc("GetStatusRaw():",1); resFilePath = new String(resFilePath); var status = {code:RES_UNKNOWN, curRes:null, versions:[]}; if (!resFilePath.getParentPart()){ var parent = DOpus.FSUtil.Resolve("/dopusdata/script addins"); resFilePath = parent + "\\" + resFilePath; } try{ if (!this.fso.FileExists(resFilePath)) throw new Error(ERR_FILE_NOT_FOUND, ERRMSGS[ERR_FILE_NOT_FOUND]); var res = ResParser.Load(resFilePath) //todo status.curRes = res; if (!res.url) throw new Error(ERR_RES_NORESURL, ERRMSGS[ERR_RES_NORESURL]); if (!res.version) throw new Error(ERR_RES_NOVERSION, ERRMSGS[ERR_RES_NOVERSION]); this.progress && this.progress.SetStatus("Searching for updates.."); var versions = this.GetAvailableVersions(res); if (!versions.length) throw new Error(ERR_RES_NOVERSIONS, ERRMSGS[ERR_RES_NOVERSIONS]); status.versions = versions; out.dmp("Script version: "+status.curRes.version); out.dmp("Latest version: "+status.versions[0].version); if (status.versions[0].version == 0) throw new Error(ERR_RES_NOVERSIONDOWN, ERRMSGS[ERR_RES_NOVERSIONDOWN]); switch (ResParser.Compare(status.curRes.version, status.versions[0].version, {lexicographical:true, zeroExtend:true})){ case 1: //curRes lower status.code += RES_UPDATE_FOUND; break; case 0: //equal status.code += RES_UPTODATE; break; case -1: //curRes more recent status.code += RES_MORERECENT; break; } if (res.modified) status.code += RES_MODIFIED; } catch(e){ out.trc("",-1); throw e; } out.trc("",-1); return status; } /////////////////////////////////////////////////////////////////////////// this.UpdateCheckAll = function( scriptsFolderPath ){ this.PrintHeader("ScriptWizard - Check ALL"); out.put("UpdateCheckAll():",1); var scriptsFolder = this.fso.GetFolder(scriptsFolderPath); var fEnum = new Enumerator(scriptsFolder.files); if (this.progress) this.progress = this.OpenProgressDialog(this.win, "ScriptWizard Check - All", scriptsFolder.files.count); var results = { updateable:0, uptodate:0, updated:0, unsupported:0, morerecent:0, failed:0, na:0}; for (var count=0; !fEnum.atEnd(); fEnum.moveNext()){ if (!ResParser.ValidateExtension(fEnum.item(), false)){ this.progress && this.progress.StepFiles(1); continue; } count++; var status = this.UpdateCheck(fEnum.item(), false); this.CountResults(results, status); this.progress && this.progress.StepFiles(1); } out.put("").put("",-1); this.PrintResults(results, count); this.progress && this.progress.Hide(); return COMMAND_SUCCEEDED; } /////////////////////////////////////////////////////////////////////////// this.UpdateAll = function( scriptsFolderPath ){ this.PrintHeader("ScriptWizard - ALL"); out.put("UpdateAll():",1); var scriptsFolder = this.fso.GetFolder(scriptsFolderPath); if (this.progress) this.progress = this.OpenProgressDialog(this.win, "ScriptWizard - All", scriptsFolder.files.count); var fEnum = new Enumerator(scriptsFolder.files); var results = { updateable:0, uptodate:0, updated:0, unsupported:0, morerecent:0, failed:0, na:0}; for (var count=0; !fEnum.atEnd(); fEnum.moveNext()){ if (!ResParser.ValidateExtension(fEnum.item(), false)){ this.progress && this.progress.StepFiles(1); continue; } count++; var status = this.Update(fEnum.item(), false); this.CountResults(results, status); this.progress && this.progress.StepFiles(1); } out.put("").put("",-1); this.PrintResults(results, count); this.progress && this.progress.Hide(); return COMMAND_SUCCEEDED; } /////////////////////////////////////////////////////////////////////////// this.PrintHeader = function(text){ out.put("--------------------------------------------------------------------------------"); out.put(text + " - " + new Date().formatDate()+ " " + new Date().formatTime()); out.put("--------------------------------------------------------------------------------"); } /////////////////////////////////////////////////////////////////////////// this.CountResults = function(results, status){ if (status.code & RES_UPDATE_FOUND) results.updateable++; else if (status.code & RES_UPTODATE) results.uptodate++; else if (status.code & RES_MORERECENT) results.morerecent++; else if (status.code & RES_UPDATED) results.updated++; else if (status.code == RES_UPDATE_UNSUPPORTED) results.unsupported++; else if (status.code == RES_STATUS_FAILED) results.failed++; else { results.na++; } } /////////////////////////////////////////////////////////////////////////// this.PrintResults = function(results, count){ out.put("Results",1); out.put("Updateable : " + results.updateable); out.put("Uptodate : " + results.uptodate); out.put("MoreRecent : " + results.morerecent); out.put("Updated : " + results.updated); out.put("Unsupported : " + results.unsupported); out.put("Failed : " + results.failed); out.put("? : " + results.na,-1); out.put(t("req.results.total", count)); out.put(""); if (this.showResults){ var msg = t("req.results.header")+ t("req.results.updateable", results.updateable)+ t("req.results.uptodate", results.uptodate)+ t("req.results.unsupported", results.unsupported)+ t("req.results.failed", results.failed)+ t("req.results.na", results.na)+ t("req.results.total", count); Request(msg,t("button.ok"),t("req.results.title"),"info",this.win); } } /////////////////////////////////////////////////////////////////////////// this.GetAvailableVersions = function( resource, attemptNum ){ attemptNum = attemptNum || 1; out.trc("GetAvailableVersions():",1); try{ var down = this.Download(resource.url); var doRTP = new DOResourceThreadParser(); var versions = doRTP.GetResourceDownloads(down.content, resource); out.trc("",-1); return versions; } catch(e){ //scriptwizard alternative download location #1 out.wrn("Error: " + attemptNum); if (resource.uid == "D4072BDA-B049-4A11-8B40-266E083D6F2D" && attemptNum<3){ //F //alternative download location for sw #1 if (attemptNum==1) resource["url"] = "http://www.steax.net/dopus/scriptwizard.htm"; //alternative download location for sw #2 if (attemptNum==2) resource["url"] = "http://www.steax.net/dopus/scriptwizard.htm"; out.wrn("ScriptWizard update (attempt "+attemptNum+") failed."); out.wrn("Trying alternative download location: " + resource.url); attemptNum++; try{ return this.GetAvailableVersions( resource, attemptNum); } catch (e){ out.trc("",-1); throw e; } } out.trc("",-1); throw e; } } /////////////////////////////////////////////////////////////////////////// this.Download = function(url, binary){ out.trc("Download():",1) if (!binary) binary = false; var result = { status:200, content:""}; var versions = ['MSXML2.XMLHTTP', 'Microsoft.XMLHTTP','MSXML.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP', 'WinHttp.WinHttpRequest','WinHttp.WinHttpRequest.5.1','MSXML2.ServerXMLHTTP']; try{ for (var i=0;i 1){ out.dmp("Sorting resources for best match"); resourcesIndexed = resourcesIndexed.sort( function(a,b){ return b.distance - a.distance; } ); bestMatchRes = resourcesIndexed[0]; } var resVersions = []; if (bestMatchRes){ if (resourcesIndexed.length > 1 && bestMatchRes.distance < 0.8){ out.inf("Best matching resource name is too different, name ["+ bestMatchRes.versions[0].fileName+"], distance ["+bestMatchRes.distance+"]"); //DumpObject(bestMatchRes); //DumpObject(bestMatchRes.versions[0]); } else { if (resourcesIndexed.length == 1 && bestMatchRes.distance < 0.8) out.wrn("Resource name is very different, name ["+ bestMatchRes.versions[0].fileName+"], distance ["+bestMatchRes.distance+"]"); resVersions = bestMatchRes.versions; out.dmp("Best matching resource name: " + resVersions[0].fileName); //sort sub resource versions out.dmp("Versions found: " + resVersions.length); resVersions.versions = resVersions.sort( function(a,b){ return ResParser.Compare(a.version, b.version, {lexicographical:true, zeroExtend:true} ); } ); } } else { out.dmp("No matching resource found"); } return resVersions; } /////////////////////////////////////////////////////////////////////////// this.GetResourcesFromXMLDoc = function(xmlDoc, cleanFileNameOfResource2Update){ var resources = []; var resourcesFound = 0; var ScriptVersion = function(){}; var fileNodes = xmlDoc.selectNodes("(//div[@class='postbody'])[1]//dl[@class='file']/dt/a[@class='postlink']/../.."); out.dmp("Downloads found: " + fileNodes.length,1); for(var f=0;f/,""); //get rid of dtd xmlText = xmlText.replace(//,""); //get rid of namespacing xmlText = xmlText.replace(/\&bull\;/g,''); //get rid of some entities xmlText = xmlText.replace(/\»\;/g,''); xmlText = xmlText.replace(/\ \;/g,''); xmlText = xmlText.replace(/\®\;/g,''); xmlText = xmlText.replace(/\©\;/g,''); xmlText = xmlText.replace(/\ü\;/g,'ü'); xmlText = xmlText.replace(/\ä\;/g,'ä'); xmlText = xmlText.replace(/\ö\;/g,'ö'); xmlText = xmlText.replace(/\·\;/g,'.'); //remove li and ul tags as they often don't match and site cannot be parsed xmlText = xmlText.replace(//g,''); xmlText = xmlText.replace(/<\/li>/g,''); xmlText = xmlText.replace(//g,''); xmlText = xmlText.replace(/<\/ul>/g,''); //fix iframe attribute with no value // ..allowfullscreen>.. xmlText = xmlText.replace(/allowfullscreen\>/g,'allowfullscreen="">'); //fix unclosed meta-tags xmlText = xmlText.replace(//g,''); //fix leos faq link xmlText = xmlText.replace(/viewtopic\.php\?f\=11\&t\=4095/g,''); //xmlText = '' + xmlText; return xmlText; } /////////////////////////////////////////////////////////////////////////// this.ParseSize = function(str){ var re = new RegExp("\(\\d{1,3}\.?\\d{1,3}?\\s..?\)",'gi'); var match = re.exec(str); if (match) return match[1]; return ""; } /////////////////////////////////////////////////////////////////////////// this.ParseVersion = function(str){ var re = new RegExp("(\\d{1,3}(?:\\.\\d{1,3})?(?:\\.\\d{1,6})?)",'gi'); var match = re.exec(str); if (match) return match[1]; return "0"; } /////////////////////////////////////////////////////////////////////////// this.GetXMLDoc = function(){ out.trc("GetXMLDoc():",1); try { var xmlDoc = new ActiveXObject("MSXML2.DOMDocument.6.0"); xmlDoc.async = false; xmlDoc.validateOnParse = true; xmlDoc.resolveExternals = false; } catch (e) { out.trc("",-1); throw e; } out.trc("",-1); return xmlDoc; } /////////////////////////////////////////////////////////////////////////// this.Distance = function(str1, str2) { var levenshtein = function(str1, str2) { var current = [], prev, value; for (var i = 0; i <= str2.length; i++) for (var j = 0; j <= str1.length; j++) { if (i && j) if (str1.charAt(j - 1) === str2.charAt(i - 1)) value = prev; else value = Math.min(current[j], current[j - 1], prev) + 1; else value = i + j; prev = current[j]; current[j] = value; } return current.pop(); }; if (str1 === null && str2 === null) throw 'Trying to compare two null values'; if (str1 === null || str2 === null) return 0; str1 = String(str1); str2 = String(str2); var distance = levenshtein(str1, str2); if (str1.length > str2.length) { return 1 - distance / str1.length; } else { return 1 - distance / str2.length; } } } /////////////////////////////////////////////////////////////////////////////// function DOResourceOutline(){ this.type = "script"; //script this.package = false; this.fileName = ""; //filename only this.extension = ""; //js, vbs, pyt or osp (additional .txt autom. removed) this.md5 = ""; //md5 internally stored this.desc = ""; //script internal or download description this.version = "0"; //version this.url = ""; //resource center thread url this.details = ""; //resource center download details this.sizeFriendly = ""; //resource center download size } /////////////////////////////////////////////////////////////////////////////// function DOResource(){ this.type = "script"; this.package = false; this.filePath = ""; //path to resource including filename this.fileName = ""; //filename only this.scriptName = ""; //diff. from filename if package this._content = ""; //file content this._onAbout = false; //has onabout function this.extension = ""; //js, vbs, pyt or osp (additional .txt autom. removed) this.md5 = ""; //md5 internally stored this.md5Fresh = ""; //md5 determined this.modified = null; //md5 different from internal md5 this.enabled = null; this.name = ""; //do script/resource name this.desc = ""; //internal or download description this.copyright = ""; //internal this.version = "0"; //version this.minVersion = ""; //do min version this.uid = ""; //internal unique id this.doID = ""; //do internal script id this.url = ""; //resource center thread url this._urlInternal = false; //url provided by resource this.details = ""; //resource center download details this.size = 0; //file size this.sizeFriendly = ""; //resource center download size } /////////////////////////////////////////////////////////////////////////////// function PackageHelper( filePath){ this.filePath = filePath; this.fileName = this.filePath.getFilePart(); this.tmpPath = ""; this.fso = FSMagic.fso; /////////////////////////////////////////////////////////////////////////// this.Extract = function(){ out.trc("Extract():",1); var cmd = DOpus.Create.Command; var tmpPath = FSMagic.GetTmpFileName(); //prepare tmp copy of package file with added .zip extension, //to allow extracting with the internal "copy" raw command var tmpPathOSP = FSMagic.GetTmpFileName("", ".zip"); if(!FSMagic.CreatePath(tmpPath.fullname)){ out.trc("",-1); throw "Creating tmp folder failed ["+tmpPath.fullname+"]"; } if(!FSMagic.CreatePath(tmpPathOSP.path)){ out.trc("",-1); throw "Creating tmp folder for OSP failed ["+tmpPathOSP.path+"]"; } out.dmp('Copy file="'+this.filePath+'" to="'+tmpPathOSP.path+'" as "'+tmpPathOSP.name+'"'); cmd.RunCommand('Copy file="'+this.filePath+'" to="'+tmpPathOSP.path+'" as "'+tmpPathOSP.name+'"'); this.tmpPath = tmpPath.fullname; out.dmp('Copy EXTRACT FILE="'+tmpPathOSP.fullname+'" TO="'+this.tmpPath+'"'); cmd.RunCommand('Copy EXTRACT FILE="'+tmpPathOSP.fullname+'" TO="'+this.tmpPath+'"'); out.dmp('Delete '+tmpPathOSP.fullname + ' ' + Script.Config["Log.What.KeepTmpFiles"]); if (Script.Config["Log.What.KeepTmpFiles"]) this.fso.DeleteFile(tmpPathOSP.fullname); out.trc("",-1); return this; } /////////////////////////////////////////////////////////////////////////// this.FindMainScriptResource = function(){ out.trc("FindMainScriptResource():",1); var folder = this.fso.GetFolder( this.tmpPath ); var fEnum = new Enumerator(folder.files); var file = null; var res = null; for (; !fEnum.atEnd(); fEnum.moveNext()){ file = fEnum.item(); if (!ResParser.ValidateExtension(file.Name, false)){ out.dmp("No valid resource ["+file.Name+"]"); continue; } res = ResParser.Load(this.tmpPath+"\\"+file.Name); if (res.package) continue; if (res.url && res._urlInternal || res.uid){ out.dmp("Using package file ["+res.fileName+"]"); break; } } out.trc("",-1); return res; } /////////////////////////////////////////////////////////////////////////// this.CleanUp = function(){ out.trc("CleanUp():",1); this.fso.DeleteFolder(this.tmpPath); out.trc("",-1); } } /////////////////////////////////////////////////////////////////////////////// function DOResourceParser(){ this.reMD5 = "(?://|'|#)MD5\\s*=\\s*[\"'](.*?)[\"']"; this.fso = new ActiveXObject("Scripting.FileSystemObject"); this.comment = {js:"//", vbs:"'", pyt:"#"}; /////////////////////////////////////////////////////////////////////////// this.ValidateExtension = function(file, throwEx, silent){ silent || out.trc("ValidateExtension(): ["+file+"]",1); if (throwEx==undefined) throwEx=true; var typeMatch = new RegExp("(?:.*?)\\.(js|vbs|pyt|osp)(?:\\.txt)?$","gi").exec(file); if (typeMatch==null || typeMatch.length!=2){ silent || out.dmp("INVALID"); silent || out.trc("",-1); if (throwEx) throw new Error(ERR_BAD_FILETYPE, ERRMSGS[ERR_BAD_FILETYPE]); return false; } silent || out.dmp("Valid"); silent || out.trc("",-1); return typeMatch[1].toLowerCase(); } /////////////////////////////////////////////////////////////////////////// this.Load = function(filePath){ out.trc("Load():",1); out.dmp("File:"+filePath); filePath = new String(filePath); if (!filePath) throw t("exception.no_file_given"); var content = ""; var reMD5 = new RegExp(this.reMD5,"gi"); var res = new DOResource(); var parent = filePath.getParentPart(); if (!parent){ parent = DOpus.FSUtil.Resolve("/dopusdata/script addins"); filePath = parent + "\\" + filePath; } if (!this.fso.FolderExists(parent)){ out.xit(t("exception.archives_nogood", parent)); out.trc("",-1); throw new Error(t("exception.archives_nogood", parent)); } res.filePath = filePath; res.fileName = filePath.getFilePart(); res.scriptName = res.fileName; res.extension = this.ValidateExtension(res.filePath); res.package = this.IsPackage(res.filePath); res.size = this.fso.GetFile(res.filePath).Size; if (!res.package){ var doScriptConfigDetails = this.GetDOScriptConfigDetails(res.filePath); res.doID = doScriptConfigDetails.id; res.enabled = doScriptConfigDetails.enabled; } if (res.package){ var ph = new PackageHelper( res.filePath ); var pRes = ph.Extract().FindMainScriptResource(); ph.CleanUp(); if (pRes){ pRes.filePath = res.filePath; pRes.scriptName = pRes.fileName; pRes.fileName = res.fileName; pRes.package = res.package; pRes.size = res.size; var doScriptConfigDetails = this.GetDOScriptConfigDetails(pRes.filePath+"\\"+pRes.scriptName); pRes.doID = doScriptConfigDetails.id; pRes.enabled = doScriptConfigDetails.enabled; out.trc("",-1); return pRes; } throw t("exception.no_script_in_pkg"); } out.dmp("Opening and reading file"); var file = this.fso.OpenTextFile( res.filePath, 1, false, -2); while(!file.AtEndOfStream){ var line = file.ReadLine(); if (line=="") continue; var md5Match = reMD5.exec(line); if (!md5Match) //skip the hash line content += line; else res.md5 = md5Match[1]; } out.dmp("Closing file"); file.Close(); out.dmp("Calculating MD5 hash (takes some time on XP).."); res.md5Fresh = MD5(content); out.dmp(" done"); res._content = content; if (res.md5!="") res.modified = (res.md5+""!=""+res.md5Fresh); out.dmp("Getting properties"); res.name = this._GetName(res); res.desc = this._GetDesc(res); res.copyright = this._GetCopyright(res); res.version = this._GetVersion(res); //DOpus.Output(res.version); res.minVersion = this._GetMinVersion(res); res.uid = this._GetUID(res); res.url = this._GetUrl(res); res._onAbout = this._GetOnAbout(res); out.dmp("done"); out.trc("",-1); return res; } /////////////////////////////////////////////////////////////////////////// this.IsPackage = function(filePath){ out.trc("IsPackage(): ["+filePath+"]",1); if (filePath && filePath.match( new RegExp( "\\.osp$", "gi"))){ out.trc("YES",-1); return true; } out.trc("NO",-1); return false; } /////////////////////////////////////////////////////////////////////////// this.Compare_old = function(verStrA,verStrB){ verStrA = this.CleanVer(verStrA); verStrB = this.CleanVer(verStrB); if (verStrA > verStrB) return -1; if (verStrA == verStrB) return 0; if (verStrA < verStrB) return 1; } /////////////////////////////////////////////////////////////////////////// this.Compare_ToTest_HandlesAlphaChars = function (v1, v2, options){ var zeroExtend = options && options.zeroExtend, v1parts = v1.split('.'), v2parts = v2.split('.'); if (zeroExtend) { while (v1parts.length < v2parts.length) v1parts.push("0"); while (v2parts.length < v1parts.length) v2parts.push("0"); } for (var i = 0; i < v1parts.length; ++i) { if (v2parts.length == i) { return 1; } var v1Int = parseInt(v1parts[i], 10); var v2Int = parseInt(v2parts[i], 10); if (v1Int == v2Int) { var v1Lex = v1parts[i].substr((""+v1Int).length); var v2Lex = v2parts[i].substr((""+v2Int).length); if (aLex === '' && bLex !== '') return 1; if (aLex !== '' && bLex === '') return -1; if (aLex !== '' && bLex !== '') return aLex > bLex ? 1 : -1; continue; } else if (v1Int > v2Int) { return 1; } else { return -1; } } if (v1parts.length != v2parts.length) { return -1; } return 0; } ////////////////////////////////////////////////////////////////////////// this.Compare = function(v1, v2, options){ //fixed by tbone for versions with no "." //compares two software version numbers (e.g. "1.7.1" or "1.2b") //copyright by Jon Papaioannou (["john", "papaioannou"].join(".") + "@gmail.com") //this function is in the public domain. do what you want with it, no strings attached. var lexicographical = options && options.lexicographical, zeroExtend = options && options.zeroExtend, v1parts = v1.split('.'), v2parts = v2.split('.'); function isValidPart(x) { return (lexicographical ? /^\d+[A-Za-z]*$/ : /^\d+$/).test(x); } for(var v=0;v Number(v2parts[i])) { return -1; } else { return 1; } } if (v1parts.length != v2parts.length) { return 1; } return 0; } /////////////////////////////////////////////////////////////////////////// this.GetDOScriptConfigDetails = function( filePath){ out.trc("GetDOScriptConfigDetails():",1); filePath = new String(filePath); var id = ""; var enabled = null; var scriptFileName = filePath.getFilePart(); var isPackage = this.IsPackage(scriptFileName); if (isPackage) scriptFileName += "\\"; //to match attribute value "*.osp\" var doScriptConfig = ""+DOpus.FSUtil.Resolve("/dopusdata/configfiles/scriptconfig.oxc"); if (typeof ScriptConfigXMLDoc == 'undefined'){ ScriptConfigXMLDoc = new ActiveXObject("MSXML2.DOMDocument.6.0"); out.dmp("DO config path: " + doScriptConfig); out.dmp("Script path: " + filePath); out.dmp("Script file: " + scriptFileName); ScriptConfigXMLDoc.async = false; ScriptConfigXMLDoc.validateOnParse = true; ScriptConfigXMLDoc.resolveExternals = false; out.dmp("Loading config"); ScriptConfigXMLDoc.load(doScriptConfig); if (ScriptConfigXMLDoc.parseError.errorCode != 0) { var myErr = ScriptConfigXMLDoc.parseError; out.err("Parser error: " + myErr.reason); out.trc("",-1); delete ScriptConfigXMLDoc; return {id:id, enabled: enabled}; } } out.dmp("Looking for nodes"); var scriptNode = ScriptConfigXMLDoc.selectSingleNode("//script[starts-with(@path,'"+scriptFileName+"')]"); //@path='"+scriptFileName+"' if (!scriptNode){ var msg = t("exception.script_not_found", scriptFileName); out.dmp(msg); //get new guid and remove curly brackets id = new ActiveXObject("Scriptlet.TypeLib").Guid.replace(/\{/gi,"").replace(/}.*/,""); out.trc("",-1); return {id:id, enabled: enabled}; } id = scriptNode.getAttribute("id"); enabled = scriptNode.getAttribute("disable")=="no"?true:false; out.dmp("done"); out.trc("",-1); return {id:id, enabled: enabled}; } /////////////////////////////////////////////////////////////////////////// this.CleanVer = function(verString){ var vTmp = ""; while (vTmp != verString){ vTmp = verString; verString = verString.replace(/\.0*$/,""); } return verString; } /////////////////////////////////////////////////////////////////////////// this._ParseOnInitProperty = function(res, regEx, resultIndex ){ var reOnInit = "(?:function\\s+OnInit[\\s\\S]*?)"; var reOnInit = "(?:function\\s+OnInit.*?)"; str = res._content; var re = new RegExp(reOnInit+regEx,"gim"); var result = re.exec(res._content); if (result != null){ //for (var i=0;i", "req.prepare.nourl.skip" : "Continue without url (not recommended, the script cannot be updated by its users)", "req.prepare.nourl.myself" : "I will add the url string to the script myself", "req.prepare.url_err.title" : "PrepareUpload - Url Error", "req.prepare.url_err.text" : "It looks like the url or line of code is invalid.\n"+ "Make sure to keep the code syntax correct.\n\n"+ "The url itself needs to match the following pattern:\n"+ "http(s):///viewtopic.php?f=XX&t=XXXXX", // "req.prepare.noabout.title" : "PrepareUpload - No About", "req.prepare.noabout.text" : "No OnAboutScript() function found!\n\n"+ "The script does not yet contain an OnAboutScript() function.\n"+ "A very tiny function will be added, which makes use of the ScriptHelper about dialog.\n"+ "The dialog offers updating, archiving and many more directly from the script preferences.", "req.prepare.noabout.skip" : "No dialog (not recommended, the script cannot be easily maintained or updated by its users)", // "req.prepare.nover.title" : "PrepareUpload - No Version", "req.prepare.nover.text" : "No version information found!\n\n"+ "The script does not yet seem to contain a version string.\n"+ "Please add it manually, by setting the onInitData.version property.", "req.prepare.nover.skip" : "Continue without version (not recommended, the script cannot be updated by its users)", // "req.prepare.nouid.title" : "PrepareUpload - No UID", "req.prepare.nouid.text" : "No UID found!\n\n"+ "The script to upload does not yet contain the dopus internal script id.\n"+ "The line displayed below will be added to the OnInit() function of your script.\n\n"+ "Your script is safe, it will be archived automatically.", "req.prepare.nouid.skip" : "Continue without UID (not recommended, the id greatly helps identifying scripts)", "req.prepare.nover.myself" : "I will add the id string to the script myself", // "req.finish.title" : "PrepareUpload - Finished for %s", "req.finish.text" : "Script successfully prepared to upload!\n\n"+ "A temporary copy has been created and its path inserted to the clipboard.\nFeel free to upload right now.\n\n"+ "Reminders:\n"+ "Did you increase the version number? If not hit ESC and restart.\n"+ "Make sure to put the new version number into the uploaded file comment.\n\n"+ "Thanks for using the ScriptWizard! o)", "req.finish.deletetmp" : "Delete the temporary script/package", "button.openthread" : "Open Thread", "button.iamdone" : "I'm done" }). AddT("de", { "button.ok" : "Ok", "button.cancel" : "Abbruch", "exception.packages_nogood" : "Script-Pakete können nicht zum Upload vorbereitet werden", "exception.addline_failed" : "Das Hinzufügen von Code zur Funktion OnInit() ist fehlgeschlagen", "exception.oninit_notfound" : "Kein passender 'OnInit'-Eintrag gefunden", "req.prepare_err.title" : "Upload vorbereiten - Fehler", "req.prepare_err.header" : "Fehler beim Vorbereiten des Scripts:\n\n%s", // "req.prepare.nourl.title" : "Upload vorbereiten - Keine Url", "req.prepare.nourl.text" : "Es wurde keine Forum-URL gefunden!\n\n"+ "Das Script enthält bisher keine URL zu seinem Forums-Beitrag.\n"+ "Kopiere die URL des Forum-Beitrags in das Textfeld unten im Dialogfenster um fortzufahren.\n\n"+ "Noch keinen Beitrag im Forum erstellt?\nDann erstelle jetzt den Beitrag um die URL zu erhalten aber lade das Script noch nicht hoch.", "req.prepare.nourl.paste" : "", "req.prepare.nourl.skip" : "Fortfahren ohne URL (nicht empfohlen, das Script kann von den Benutzern nicht aktualisiert werden)", "req.prepare.nourl.myself" : "Ich werde die URL selbst dem Script hinzufügen", "req.prepare.url_err.title" : "Upload vorbereiten - Url Fehler", "req.prepare.url_err.text" : "Die URL oder Code-Zeile scheint ungültig zu sein.\n"+ "Stelle sicher, dass die Syntax der Zeichenfolge korrekt ist.\n\n"+ "Die URL selbst muss der folgenden Form entsprechen:\n"+ "http(s):///viewtopic.php?f=XX&t=XXXXX", // "req.prepare.noabout.title" : "Upload vorbereiten - Keine OnAboutScript()-Funktion", "req.prepare.noabout.text" : "Keine OnAboutScript() Funktion gefunden!\n\n"+ "Das Script enthält bisher keine OnAboutScript()-Funktion.\n"+ "Eine kleine Funktion wird hinzugefügt, die die Schaltfläche für den Info-Dialog in den Script-Einstellungen aktiviert.\n"+ "Der Dialog bietet Möglichkeiten zum aktualisieren und archivieren von Scripts (und mehr) direkt aus dessen Einstellungen heraus.", "req.prepare.noabout.skip" : "Kein Dialog (nicht empfohlen, das Script kann von den Benutzern nicht problemlos verwaltet und aktualisiert werden)", // "req.prepare.nover.title" : "Upload vorbereiten - Keine Versionsinformation", "req.prepare.nover.text" : "Keine Versionsinformation gefunden!\n\n"+ "Das Script scheint bisher keine Versionsangabe zu enthalten.\n"+ "Füge dies bitte manuell hinzu, indem du die Eigenschaft onInitData.version setzt.", "req.prepare.nover.skip" : "Fortfahren ohne Versionsangabe (nicht empfohlen, das Script kann von den Benutzern nicht aktualisiert werden)", // "req.prepare.nouid.title" : "Upload vorbereiten - Keine UID", "req.prepare.nouid.text" : "Keine UID gefunden!\n\n"+ "Das Script enthält noch keine DOpus-interne Script-ID.\n"+ "Die unten dargestellte Zeile wird der OnInit()-Funktion des Scripts hinzugefügt.\n\n"+ "Das Original-Script ist sicher; es wird automatisch archiviert.", "req.prepare.nouid.skip" : "Ohne UID fortfahren (nicht empfohlen, die ID ist äusserst hilfreich um ScriptsScript zu identifizieren)", "req.prepare.nover.myself" : "Ich werde die ID-Zeile selbst hinzufügen", // "req.finish.title" : "Upload vorbereiten - Beendet für %s", "req.finish.text" : "Das Script wurde erfolgreich für den Upload vorbereitet!\n\n"+ "Eine temporäre Kopie wurde erstellt und ihr Pfad in die Zwischenablage kopiert.\nDu kannst sofort mit dem Upload beginnen.\n\n"+ "Checkliste:\n"+ "Hast du im Script die Versionsnummer erhöht? Wenn nicht drücke ESC und starte erneut.\n"+ "Stelle sicher, dass du die neue Versionsnummer im Kommentarfeld der hochgeladenen Datei eingetragen hast.\n\n"+ "Vielen Dank für die Verwendung von ScriptWizard! o)", "req.finish.deletetmp" : "Lösche das temporäre Script/Paket", "button.openthread" : "Öffne Forumsbeitrag", "button.iamdone" : "Ich bin fertig" }); } /////////////////////////////////////////////////////////////////////////////// function Request(txt,buttons,title,icon,win){ var dlg = DOpus.Dlg; dlg.window = (win==undefined?null:win); dlg.message = txt; dlg.title = title; dlg.buttons = buttons; dlg.icon = icon; return dlg.Show(); } /////////////////////////////////////////////////////////////////////////////// function GetParameter( data, templateName, configName, defaultValue){ // v0.8 function VectorToArray(vector){ var a = new Array(); for(var v=0;v"); if (steps==undefined) steps=1; this._indent+=steps; return this; } /////////////////////////////////////////////////////////////////////////// this.dec = function(steps){ //DOpus.Output("<"); if (steps==undefined) steps=1; this._indent-=steps; if (this._indent<0) this._indent=0; return this; } /////////////////////////////////////////////////////////////////////////// this.reset = function(){ this._indent=0; this.buffer = new Array(); return this; } /////////////////////////////////////////////////////////////////////////// this._ind = function(indent){ if (indent==undefined) return; if (indent>0) this.inc(); if (indent<0) this.dec(); } /////////////////////////////////////////////////////////////////////////// this._pad = function( length) { var str = ""; while (str.length < length) str+=this._indentChar; return str; } /////////////////////////////////////////////////////////////////////////// this.level = function(level){ if (level==undefined) level=4; if (level>-1) this._level=level; if (level>6) this._level=6; return this; } /////////////////////////////////////////////////////////////////////////// this._conOut = function(txt){ if (this._inDOP && !this._muted) DOpus.Output(txt); if (this._inWSH && !this._muted) WScript.Echo(txt); } /////////////////////////////////////////////////////////////////////////// this.out = function(txt, indent, type){ if (indent==undefined) indent=0; if (type==undefined) type=""; var indTmp = this._indent; if (type!="" && indTmp==0) indTmp=1; if (this._level>0 && (txt!="" || indent==0)){ var output = type+ this._pad(indTmp*this._indentWidth-type.length) +txt; this.outRaw(output); } this._ind(indent); return this; } /////////////////////////////////////////////////////////////////////////// this.outRaw = function(output){ if (this._buffered) this.outBuffer[this.outBuffer.length]=output; if (this._console) this._conOut(this._prepLine(output,this._lineConsole)); if (this._file) this._fileOut(this._prepLine(output,this._lineFile)); } /////////////////////////////////////////////////////////////////////////// this._fileOut = function(txt){ if (this._save && this._fso.FileExists(this._filePath)) this._fso.DeleteFile(this._filePath); this._save = false; var file = this.open(8, true); //append if (file === null) return false; try{file.WriteLine(txt);}catch(e){ txt = txt.replace(/[^ -~]/ig,''); //printable chars only file.WriteLine(txt); } file.Close(); return true; } /////////////////////////////////////////////////////////////////////////// this.append = function(filepath){ if (filepath==undefined) throw "No filepath given."; try{ this._fso = fso; } catch(e){ this._fso = new ActiveXObject("Scripting.FileSystemObject");} this._filePath = filepath; this._file = true; this.truncate(this._fileMaxSize, this._tolerance); return this; } /////////////////////////////////////////////////////////////////////////// this.save = function(filepath ){ this._save = true; return this.append(filepath); } /////////////////////////////////////////////////////////////////////////// this.max = function(maxFileSize){ this._fileMaxSize = maxFileSize; return this; } /////////////////////////////////////////////////////////////////////////// this.tolerance = function(maxFileSizeTolerancePercent){ this._tolerance = maxFileSizeTolerancePercent; return this; } /////////////////////////////////////////////////////////////////////////// this.truncate = function(maxSize, percTolerance){ if (!maxSize) return this; percTolerance = percTolerance || 0; var maxSizeTol = maxSize; if (percTolerance) maxSizeTol = maxSize+(maxSize*(percTolerance/100)); if (!this._fso.FileExists(this._filePath)) return this; var file = this.open( 1, false);//read if (file === null) return this; file.Close(); if(this._fso.GetFile(this._filePath).Size < maxSizeTol) return this; var content = [], file = this.open( 1, false); while(!file.AtEndOfStream) content[content.length] = file.ReadLine(); file.Close(); var file=this.open( 2, true); var size=2/*bom*/, startIndex=content.length, delta=0; if (file === null) return this; while(startIndex && ((size+delta)6||(this._keepInds&&indent)) this.out(txt, indent); return this; } /////////////////////////////////////////////////////////////////////////// this.trc = function(txt, indent){ if (this._level+1>5||(this._keepInds&&indent)) this.out(txt, indent); return this; } /////////////////////////////////////////////////////////////////////////// this.put = function(txt, indent){ if (this._level+1>4||(this._keepInds&&indent)) this.out(txt, indent); return this; } /////////////////////////////////////////////////////////////////////////// this.inf = function(txt, indent){ if (this._level+1>3||(this._keepInds&&indent)) this.out(txt, indent, "I"); return this; } /////////////////////////////////////////////////////////////////////////// this.wrn = function(txt, indent){ if (this._level+1>2||(this._keepInds&&indent)) this.out(txt, indent, "W"); return this; } /////////////////////////////////////////////////////////////////////////// this.err = function(txt, indent){ if (this._level+1>1||(this._keepInds&&indent)) this.out(txt, indent, "E"); return this; } /////////////////////////////////////////////////////////////////////////// this.xit = function(txt, indent){ if (this._level+1>0||(this._keepInds&&indent)) this.out(txt, indent, "X"); return this; } } /////////////////////////////////////////////////////////////////////////////// var MD5 = function(string) { /////////////////////////////////////////////////////////////////////////// function RotateLeft(lValue, iShiftBits) { return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits)); } /////////////////////////////////////////////////////////////////////////// function AddUnsigned(lX, lY) { var lX4, lY4, lX8, lY8, lResult; lX8 = (lX & 0x80000000); lY8 = (lY & 0x80000000); lX4 = (lX & 0x40000000); lY4 = (lY & 0x40000000); lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF); if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8); if (lX4 | lY4) { if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); else return (lResult ^ 0x40000000 ^ lX8 ^ lY8); } else return (lResult ^ lX8 ^ lY8); } /////////////////////////////////////////////////////////////////////////// function F(x, y, z) { return (x & y) | ((~x) & z); } /////////////////////////////////////////////////////////////////////////// function G(x, y, z) { return (x & z) | (y & (~z)); } /////////////////////////////////////////////////////////////////////////// function H(x, y, z) { return (x ^ y ^ z); } /////////////////////////////////////////////////////////////////////////// function I(x, y, z) { return (y ^ (x | (~z))); } /////////////////////////////////////////////////////////////////////////// function FF(a, b, c, d, x, s, ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; /////////////////////////////////////////////////////////////////////////// function GG(a, b, c, d, x, s, ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; /////////////////////////////////////////////////////////////////////////// function HH(a, b, c, d, x, s, ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; /////////////////////////////////////////////////////////////////////////// function II(a, b, c, d, x, s, ac) { a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)); return AddUnsigned(RotateLeft(a, s), b); }; /////////////////////////////////////////////////////////////////////////// function ConvertToWordArray(string) { var lWordCount; var lMessageLength = string.length; var lNumberOfWords_temp1 = lMessageLength + 8; var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64; var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16; var lWordArray = Array(lNumberOfWords - 1); var lBytePosition = 0; var lByteCount = 0; while (lByteCount < lMessageLength) { lWordCount = (lByteCount - (lByteCount % 4)) / 4; lBytePosition = (lByteCount % 4) * 8; lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition)); lByteCount++; } lWordCount = (lByteCount - (lByteCount % 4)) / 4; lBytePosition = (lByteCount % 4) * 8; lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition); lWordArray[lNumberOfWords - 2] = lMessageLength << 3; lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29; return lWordArray; }; /////////////////////////////////////////////////////////////////////////// function WordToHex(lValue) { var WordToHexValue = "", WordToHexValue_temp = "", lByte, lCount; for (lCount = 0; lCount <= 3; lCount++) { lByte = (lValue >>> (lCount * 8)) & 255; WordToHexValue_temp = "0" + lByte.toString(16); WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2); } return WordToHexValue; }; /////////////////////////////////////////////////////////////////////////// function Utf8Encode(string) { string = string.replace(/\r\n/g, "\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if ((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }; /////////////////////////////////////////////////////////////////////////// var x = Array(); var k, AA, BB, CC, DD, a, b, c, d; var S11 = 7, S12 = 12, S13 = 17, S14 = 22, S21 = 5, S22 = 9, S23 = 14, S24 = 20; var S31 = 4, S32 = 11, S33 = 16, S34 = 23, S41 = 6, S42 = 10, S43 = 15, S44 = 21; string = Utf8Encode(string); x = ConvertToWordArray(string); a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476; for (k = 0; k < x.length; k += 16) { AA = a; BB = b; CC = c; DD = d; a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478); d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756); c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB); b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE); a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF); d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A); c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613); b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501); a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8); d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF); c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1); b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE); a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122); d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193); c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E); b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821); a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562); d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340); c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51); b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA); a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D); d = GG(d, a, b, c, x[k + 10], S22, 0x2441453); c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681); b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8); a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6); d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6); c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87); b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED); a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905); d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8); c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9); b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A); a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942); d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681); c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122); b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C); a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44); d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9); c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60); b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70); a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6); d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA); c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085); b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05); a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039); d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5); c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8); b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665); a = II(a, b, c, d, x[k + 0], S41, 0xF4292244); d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97); c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7); b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039); a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3); d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92); c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D); b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1); a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F); d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0); c = II(c, d, a, b, x[k + 6], S43, 0xA3014314); b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1); a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82); d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235); c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB); b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391); a = AddUnsigned(a, AA); b = AddUnsigned(b, BB); c = AddUnsigned(c, CC); d = AddUnsigned(d, DD); } var temp = WordToHex(a) + WordToHex(b) + WordToHex(c) + WordToHex(d); return temp.toLowerCase(); } /////////////////////////////////////////////////////////////////////////////// function OnAddColumns(data){ /////////////////////////////////////////////////////////////////////////// Translator. AddT("en", { "column.name.header" : "Name", "column.name.label" : "SWizard.Name", "column.description.header" : "Description", "column.description.label" : "SWizard.Description", "column.copyright.header" : "Copyright", "column.copyright.label" : "SWizard.Copyright", "column.enabled.header" : "Enabled", "column.enabled.label" : "SWizard.Enabled", "column.version.header" : "Version", "column.version.label" : "SWizard.Version", "column.minversion.header" : "MinVersion", "column.minversion.label" : "SWizard.MinVersion", "column.status.header" : "Status", "column.status.label" : "SWizard.Status", "column.modified.header" : "Modified", "column.modified.label" : "SWizard.Modified", "column.url.header" : "Url", "column.url.label" : "SWizard.Url", "column.info.header" : "Information", "column.info.label" : "SWizard.Information" }). AddT("de", { "column.name.header" : "Name", "column.name.label" : "SWizard.Name", "column.description.header" : "Beschreibung", "column.description.label" : "SWizard.Beschreibung", "column.copyright.header" : "Copyright", "column.copyright.label" : "SWizard.Copyright", "column.enabled.header" : "Aktiviert", "column.enabled.label" : "SWizard.Aktiviert", "column.version.header" : "Version", "column.version.label" : "SWizard.Version", "column.minversion.header" : "MinVersion", "column.minversion.label" : "SWizard.MinVersion", "column.status.header" : "Status", "column.status.label" : "SWizard.Status", "column.modified.header" : "Modifiziert", "column.modified.label" : "SWizard.Modifiziert", "column.url.header" : "Url", "column.url.label" : "SWizard.Url", "column.info.header" : "Information", "column.info.label" : "SWizard.Information" }); var col = data.AddColumn(); col.multicol = true; col.name = "Name"; col.method = "Column_ScriptDetails_Multi"; col.autorefresh = true; col.namerefresh = true; col.justify = "left"; col.defwidth = "175px"; tc(col); var col = data.AddColumn(); col.multicol = true; col.name = "Description"; col.method = "Column_ScriptDetails_Multi"; col.autorefresh = true; col.namerefresh = true; col.justify = "left"; col.defwidth = "175px"; tc(col); var col = data.AddColumn(); col.multicol = true; col.name = "Copyright"; col.method = "Column_ScriptDetails_Multi"; col.autorefresh = true; col.namerefresh = true; col.justify = "left"; col.defwidth = "175px"; tc(col); var col = data.AddColumn(); col.multicol = true; col.name = "Version"; col.method = "Column_ScriptDetails_Multi"; col.autorefresh = true; col.namerefresh = true; col.justify = "left"; col.defwidth = "45px"; tc(col); var col = data.AddColumn(); col.multicol = true; col.name = "MinVersion"; col.method = "Column_ScriptDetails_Multi"; col.autorefresh = true; col.namerefresh = true; col.justify = "left"; col.defwidth = "45px"; tc(col); var col = data.AddColumn(); col.multicol = true; col.name = "Modified"; col.method = "Column_ScriptDetails_Multi"; col.autorefresh = true; col.namerefresh = true; col.justify = "right"; col.defwidth = "50px"; tc(col); var col = data.AddColumn(); col.multicol = true; col.name = "Url"; col.method = "Column_ScriptDetails_Multi"; col.autorefresh = true; col.namerefresh = true; col.justify = "left"; col.defwidth = "300px"; tc(col); var col = data.AddColumn(); col.multicol = true; col.name = "Info"; col.method = "Column_ScriptDetails_Multi"; col.autorefresh = true; col.namerefresh = true; col.justify = "left"; col.defwidth = "300px"; tc(col); //single columns var col = data.AddColumn(); col.name = "Status"; col.method = "Column_ScriptStatus_Single"; col.autorefresh = true; col.namerefresh = true; col.justify = "center"; col.defwidth = "80px"; tc(col); var col = data.AddColumn(); col.name = "Enabled"; col.method = "Column_ScriptEnabled_Single"; col.autorefresh = true; col.namerefresh = true; col.justify = "right"; col.defwidth = "50px"; tc(col); } /////////////////////////////////////////////////////////////////////////// Translator. AddT("en", { "column.enabled.yes" : "yes", "column.enabled.no" : "no", "column.modified.yes" : "yes", "column.modified.no" : "no", "column.modified.unknown" : "?", "column.status.old" : "old", "column.status.uptodate" : "uptodate", "column.status.newer" : "newer" }). AddT("de", { "column.enabled.yes" : "ja", "column.enabled.no" : "nein", "column.modified.yes" : "ja", "column.modified.no" : "nein", "column.modified.unknown" : "?", "column.status.old" : "veraltet", "column.status.uptodate" : "aktuell", "column.status.newer" : "neuer" }); /////////////////////////////////////////////////////////////////////////////// function Column_ScriptStatus_Single(data) { if (data.item.is_dir) return; if (!ResParser.ValidateExtension(data.item.name, false, true)) return; out.trc("Column_ScriptStatus_Single(): ["+data.item.name+"]",1); ColCache.Initialize(data); var cacheItem = ColCache.LookupItem(data.item); if (!cacheItem || cacheItem.isModified || cacheItem.isExpired){ out.dmp("Creating new item"); cacheItem = ColCache.CreateItem(data.item, cacheItem); } out.dmp(" Modified: " + cacheItem.isModified); out.dmp(" Expired : " + cacheItem.isExpired + ", expires in " + cacheItem.ExpirationHours() + " hours." ); out.dmp("Status: " + cacheItem.GetColumn("Status")); if (cacheItem.GetColumn("Status")!==undefined){ out.dmp("Using cached column values"); cacheItem.ExportColumns(); out.trc("",-1); return; } out.dmp("*NOT* using cached item values, getting fresh values"); try{ ColCache.SetColumns(""); out.mute(false); var resUp = new DOResourceUpdater(); resUp.interactive = false; resUp.progress = false; resUp.showResults = false; resUp.win = null; var statusTxt = ""; var status = resUp.UpdateCheck(data.item, true); if (status.code & RES_UPDATE_FOUND) statusTxt=t("column.status.old"); else if (status.code & RES_UPTODATE) statusTxt=t("column.status.uptodate"); else if (status.code & RES_MORERECENT) statusTxt=t("column.status.newer"); else if (status.code == RES_UPDATE_UNSUPPORTED) statusTxt="?"; else if (status.code == RES_STATUS_FAILED) statusTxt ="error"; else statusTxt="?"; data.value = statusTxt; cacheItem.ImportColumns().Save(); } catch(e){ out.xit("SEVERE ERROR: " + e.toString()); } out.trc("",-1); } /////////////////////////////////////////////////////////////////////////////// function Column_ScriptEnabled_Single(data) { if (data.item.is_dir) return; if (!ResParser.ValidateExtension(data.item.name, false, true)) return; if (Script.Config["Log.What.Columns"]) out.mute(false); else out.mute(true); out.trc("Column_ScriptEnabled_Single(): ["+data.item.name+"]",1); try{ var scriptDetails = ResParser.GetDOScriptConfigDetails(""+data.item.realpath); if (scriptDetails.enabled===true) data.value = t("column.enabled.yes"); if (scriptDetails.enabled===false) data.value = t("column.enabled.no"); if (scriptDetails.enabled===null) data.value = "?"; } catch(e){ out.err(e);} out.trc("",-1); } /////////////////////////////////////////////////////////////////////////////// function Column_ScriptDetails_Multi(data) { if (data.item.is_dir) return; if (!ResParser.ValidateExtension(data.item.name, false, true)) return; if (Script.Config["Log.What.Columns"]) out.mute(false); else out.mute(true); out.trc("Column_ScriptDetails_Multi(): ["+data.item.name+"]",1); ColCache.Initialize( data, ["Name", "Description", "Copyright", "Version", "MinVersion", "Modified", "Url", "Info"]); var cacheItem = ColCache.LookupItem(data.item); if (!cacheItem || cacheItem.isModified || cacheItem.isExpired){ out.dmp("Creating new item"); cacheItem = ColCache.CreateItem(data.item, cacheItem); } out.dmp(" Modified: " + cacheItem.isModified); out.dmp(" Expired : " + cacheItem.isExpired + ", expires in " + cacheItem.ExpirationHours() + " hours." ); if (cacheItem.GetColumn("Name")!==undefined){ out.dmp("Using cached column values"); cacheItem.ExportColumns(); out.trc("",-1); return; } out.dmp("*NOT* using cached item values, getting fresh values"); try{ ColCache.SetColumns(""); out.mute(false); try{ var res = ResParser.Load(data.item.realpath); } catch(e){ out.err(e); out.trc("",-1); return; } if (res.name) data.columns("Name").value = res.name; if (res.desc) data.columns("Description").value = res.desc; if (res.copyright) data.columns("Copyright").value = res.copyright; if (res.version) data.columns("Version").value = res.version; if (res.minVersion) data.columns("MinVersion").value = res.minVersion; if (res.modified===false) data.columns("Modified").value = t("column.modified.no"); if (res.modified===true) data.columns("Modified").value = t("column.modified.yes"); if (res.modified===null) data.columns("Modified").value = t("column.modified.unknown"); if (res.url) data.columns("Url").value = res.url; if (!res._urlInternal) data.columns("Info").value = ERRMSGS[ERR_RES_NORESURL].replace("Unsupported: ","")+"!"; if (Script.Config["Log.What.Columns"]) out.mute(false); else out.mute(true); cacheItem.ImportColumns().Save(); } catch(e){ out.xit("SEVERE ERROR: " + e); } out.trc("",-1); } /////////////////////////////////////////////////////////////////////////////// function ColumnCache(id, enabled, msExpired, persistent, columnNames){ this.version = 0.6; this.versionData = 0.5; this.log = false; this.data = null; this.enabled = (enabled===undefined) || enabled; this.initialized = false; this.persistent = (persistent===undefined) || persistent; this.id = id; this.varName = "Script.ColumnCache."+this.id; this.msExpired = (msExpired==undefined?7*86400000/*7 days*/:msExpired); this.columnNamesAll = []; this.columnNames = []; this.columnsHash = ""; this.cacheData = null; this.cacheRoot = null; this.CACHE_DATA = 0; this.CACHE_DATA_VERSION = 1; this.CACHE_DATE_CREATED = 2; this.CACHE_COLUMNSHASH = 3; this.ITEM_ID = 0; this.ITEM_TYPE = 1; this.ITEM_DATE_MODIFIED = 2; this.ITEM_DATE_ADDED = 3; this.ITEM_COLVALUES = 4; /////////////////////////////////////////////////////////////////////////// this.Item = function(id){ this.log = false; this.cache = null; this.id = ""; this.index = null; this.type = ""; this.dateCreated = new Date().getTime(); this.dateModified = ""; this.isExpired = null; this.colValues = null; /////////////////////////////////////////////////////////////////////// this.ExpirationHours = function(){ return ((this.cache.msExpired-(new Date().getTime()-this.dateCreated))/60/60/1000).toFixed(2); } /////////////////////////////////////////////////////////////////////// this.GetColumn = function(columnName){ if (!this.cache.initialized){ this.log&&out.xit("Item.GetColumn(), Cache not initialized",-1); out.trc("",-1); return this; } //if (!this.cache.enabled){ this.log&&out.dmp("Item.GetColumn(), Cache not enabled"); out.trc("",-1); return this; } var index = this.cache.columnNamesAll[columnName]; if (index!==undefined && index 80) itemIDShort = ".."+itemID.substring(itemID.length-80); this.log&&out.trc("ColumnCache.LookupItem(): ["+itemIDShort+"]",1); for (var v=0;vthis.msExpired; item.dateModified = cacheItem(this.ITEM_DATE_MODIFIED); item.isModified = cacheItem(this.ITEM_DATE_MODIFIED)+""!=""+doItem.modify_utc; item.cache = this; return item; } } this.log&&out.dmp("not found"); this.log&&out.trc("",-1); return null; } /////////////////////////////////////////////////////////////////////////// this.Compact = function(){ this.log&&out.trc("ColumnCache.Compact(): ["+this.id+"]",1); if (!this.initialized){ //do not create cache if not exists this._InitCreate(false); } if (!this.initialized){ this.log&&out.inf("Cache is not initialized (maybe does not exist yet)"); this.log&&out.dmp("failed"); this.log&&out.trc("",-1); return false; } this.log&&out.dmp("Testing indexes [0-"+this.cacheData.length+"].."); for (var v=0;v maxLen) maxLen = prop.length; for(prop in o){ var pad = ""; while (pad.length+prop.length