/** * @file * @brief Javascript for the Clock Plugin */ // id of the clock face. DONT CHANGE THIS UNLESS YOU KNOW WHAT YOU ARE DOING! var jsclock_id= "dw_clock_object"; if(!document.getElementById("dw__editform")) { var dwClockTimer; // timer object var dwClockDOMObject; // DOM container var dwPar; } function dwclock_adjustTZ(date, tzString, localeString) { return new Date((typeof date === "string" ? new Date(date) : date).toLocaleString(localeString, {timeZone: tzString})); } // class dwClock { time_; constructor() { this.time_= new Date(); } get time() { return this.time_; } get h() { return this.time_.getHours(); } get m() { return this.time_.getMinutes(); } get s() { return this.time_.getSeconds(); } tick () { this.time_= new Date(); } format (fmt) { return time_.toLocaleString(fmt); } formatArgs (fmt, args) { return time_.toLocaleString(fmt, args); } }; class dwClock_Text extends dwClock { update ( obj ) { super.tick(); var cT= this.time; var Ahh= cT.getHours(); var Amm= cT.getMinutes(); var Ass= cT.getSeconds(); // format it as ISO 8601 text if (Ahh<=9 && Ahh>=0) Ahh= "0" + Ahh; if (Amm<=9 && Amm>=0) Amm= "0" + Amm; if (Ass<=9 && Ass>=0) Ass= "0" + Ass; var timetext= " " + Ahh + ":" + Amm + ":" + Ass + " "; // assign text to element with id as 'jsclock_id' variable obj.innerHTML= timetext; } }; function dwclock_tick () { dwClockTimer.update(dwClockDOMObject); setTimeout(dwclock_tick, 500); } jQuery( function() { if(document.getElementById("dw__editform")) { return; } dwClockDOMObject = document.getElementById(jsclock_id); dwPar= dwClockDOMObject.parentElement; dwClockTimer= new dwClock_Text(); } ); jQuery( function() { if(document.getElementById("dw__editform")) { return; } dwclock_tick(); } ); // end of clock/script.js