Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //pack_js_footer : get as parameter string like "HHMM"
- * v240117 - refreshtimeXXYY : Now I can put refreshtime09:15 to reload at 09:15
- //-------------------reload at specific times 240117 + 231011a --START-------------
- var btime = hh + mm;
- refreshAt(btime);
- }
- //https://stackoverflow.com/questions/1217929/how-to-automatically-reload-a-web-page-at-a-certain-time
- /*
- *
- * refreshAtHHMM("0335"); //Will refresh the page at 3:35pm
- *
- * To do: add refreshAt() for all breaks and execute them if activated from pack_refresh_browser().
- * The check can be done inside probeserver. It might need a global variable for break1 ,break2 etc "activated" of "completed"
- *
- */
- var refreshbreak1set=false;
- var refreshbreak2set=false;
- refreshbreak3set=false;
- var refreshbreak4set=false;
- var refreshbreak5set=false;
- var refreshbreak6set=false;
- function refreshAtHHMM(breaktime) {
- // Remove colons from breaktime
- breaktime = breaktime.replace(/:/g, '');
- var hours = breaktime.substring(0, 2);
- var minutes = breaktime.substring(2, 4);
- var seconds = "00";
- var now = new Date();
- var then = new Date();
- if(now.getHours() > hours ||
- (now.getHours() == hours && now.getMinutes() > minutes) ||
- now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >= seconds) {
- then.setDate(now.getDate() + 1);
- }
- then.setHours(hours);
- then.setMinutes(minutes);
- then.setSeconds(seconds);
- console.log("refreshAt:"+hours+minutes+seconds)
- var timeout = (then.getTime() - now.getTime());
- setTimeout(function() { window.location.reload(true); }, timeout);
- }
- //-------------------reload at specific times --END-------------
- >>>>>>>>>inside probeserver code :
- // +++++++++++++++++++=refreshtimeXXYY++++++++++++++++++++++
- if (response_string.indexOf("refreshtime") !== -1) {
- var startIndex = response_string.indexOf("refreshtime") + 11; // Start index after "refreshtime"
- var endIndex = response_string.indexOf(":", startIndex); // Index of ":" after XX
- var refreshTime;
- if (endIndex !== -1) {
- // Case: refreshtimeXX:YY
- refreshTime = response_string.substring(startIndex, endIndex) + response_string.substring(endIndex + 1);
- } else {
- // Case: refreshtimeXXYY
- refreshTime = response_string.substring(startIndex);
- }
- //console.log("RefreshTime="+refreshTime);
- refreshAtHHMM(refreshTime);
- }
- //-----------------------refreshtimeXX:YY END----------------------
- if (response_string.indexOf("breakrefresh") !== -1) {
- var s=response_string;
- //pack_refresh_browser = execute EVAL:console.log("eval-command-console.log--hello");:EVAL
- //var result = s.match(/AAAA:(.*?):BBBB/i); //OLD - ONLY for single line
- //var result = s.match(/AAAA:([\s\S]*?):BBBB/); //multi line
- //var result = s.match(/EVAL:([\s\S]*?):EVAL/); //multi line
- console.log("refreshbreak---");
- if ((response_string.indexOf("breakrefresh2")!== -1) && !refreshbreak2set ) {console.log("refreshbreak2"); refreshAt(9,"02",0); refreshbreak2set=true; }
- if ((response_string.indexOf("breakrefresh3")!== -1) && !refreshbreak3set ) {console.log("refreshbreak3"); refreshAt(9,42,0); refreshbreak3set=true; }
- if ((response_string.indexOf("breakrefresh4")!== -1) && !refreshbreak4set ) {console.log("refreshbreak4"); refreshAt(10,47,0); refreshbreak4set=true; }
- if ((response_string.indexOf("breakrefresh5")!== -1) && !refreshbreak5set ) {console.log("refreshbreak5"); refreshAt(11,33,0); refreshbreak5set=true; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement