/////////////////////////////////////////////////////////////////////////////// //DOs general script initialization function OnInit(data){ //uid added via script wizard (do not change after publishing this script) //this is not a standard DO script var/property var uid = "746ACD01-7208-4B10-A068-48CFC6903013"; //resource center url added via script wizard (allows thread visiting, updating) //this is not a standard DO script var/property var url = "http://resource.dopus.com/viewtopic.php?f=35&t=23525"; //script display name data.name = "Command.GUI: ListerClock"; //script description data.desc = "Clock in lister title (run to start, run again to exit)"; //script version data.version = "0.2"; //minimum DO version required data.min_version = "11.7.1"; //set script log prefix if supported by DO if (DOpus.Version.AtLeast("11.8.2")) data.log_prefix = "ListerClock"; //enable the script and its command by default data.default_enable = true; //register the "ListerClock" script command and connect the command to the //function below called "Command_ListerClock" var cmd = data.AddCommand(); cmd.name = "ListerClock"; cmd.method = "Command_ListerClock"; //set commands description to be the same as for the script cmd.desc = data.desc; //enable the script option "DebugOutput" by default, to print text to //the "other logs" utility pane (script console) data.config["DebugOutput"] = true; } /////////////////////////////////////////////////////////////////////////////// //main function, will be called whenever the command "ListerClock" is executed function Command_ListerClock(data) { Debug("ListerClock(): "); //do not deselect items after this command finishes data.func.command.deselect = false; //if var "Script.ListerClock" is already exists, delete it and immediately quit. //the ListerClock ran before will notice the missing variable and exit itself if (DOpus.Vars.Exists("Script.ListerClock")){ Debug(" already running"); DOpus.Vars.Delete("Script.ListerClock"); //delete the indicator variable return; } Debug(" starting"); //create and set the indicator variable DOpus.Vars.Set("Script.ListerClock") = "running"; //loop forever while (1){ //leave the loop if the var "Script.ListerClock" has been deleted if (!DOpus.Vars.Exists("Script.ListerClock")) break; var timeNow = new Date().formatTime(); //create or update readable time string //set lister title with time and version information DOpus.Create.Command.RunCommand( 'Set LISTERTITLE="'+timeNow+' - '+DOpus.version + '"'); DOpus.Delay("1000"); //wait 1 second } //exiting ListerClock here, restoring default lister title handling DOpus.Create.Command.RunCommand( 'Set LISTERTITLE=""'); Debug(" exiting.."); return; } /////////////////////////////////////////////////////////////////////////////// //add method "formatDate()" to date objects which creates a readable timestring 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; } /////////////////////////////////////////////////////////////////////////////// //prints text to the script console, if script option "DebugOutput" is enabled function Debug(text) { try{ if(Script); if (0 || Script.config.DebugOutput) DOpus.Output(text); } catch(e){ DOpus.Output(text); } } /////////////////////////////////////////////////////////////////////////////// //function to enable the "about" button in preferences / toolsbars / scripts //for this script. this button makes use of the "ScriptWizard" addin to open a //multifunctional about dialog if the add-in is present 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+'"'); } //script hash and modification time of this script //added by ScriptWizard upload preperation //MD5 = "a1997543ee354b7abf0f4361f4bfed2b"; DATE = "2014.12.06 - 13:23:13"