Last active
October 15, 2016 08:36
-
-
Save nikhilkumar13/7f8879e4441d7e2b3a9a5acf3b4e565c to your computer and use it in GitHub Desktop.
Revisions
-
Nikhil Kumar revised this gist
Oct 15, 2016 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ ////////////////// MSlib dependencies trace: Starts here ////////////////////////////// // This Script shows timer in any webpage. all you need do is execute this this script in Console. var floor = Math.floor; var int = parseInt; -
Nikhil Kumar created this gist
Oct 15, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,85 @@ ////////////////// MSlib dependencies trace: Starts here ////////////////////////////// var floor = Math.floor; var int = parseInt; function time() { return floor(new Date().getTime()/1000); } function timem() { return floor(new Date().getTime()); } function range3(a, b, c) { var outp = []; for(var i=a; i<b; i+=c) { outp.push(i); } return outp; } function range2(a, b) { return range3(a, b, 1); } function range(a) { return range2(0, a); } function zeropadding(x, num) { x = ''+x; return (range(num-x.length).map(function(){return '0';}).join('')+''+x); } function second_to_disp(x) { x = floor(x); var ms = x%1000; var seconds = int(x/1000)%60; var minutes = int(x/60000)%60; var hours = int(x/3600000); return (hours > 0 ? (hours+":") : "")+zeropadding(minutes, 2)+":"+zeropadding(seconds, 2)+":"+zeropadding(ms, 3); } ////////////////// MSlib dependencies trace: Ends here ////////////////////////////// function adddiv() { var elm = document.createElement("div"); document.body.appendChild(elm); elm.innerHTML = "Anonymous"; var style = { padding: '20px', backgroundColor: "#ccc", // border: "solid #555 2px", display: "inline-block", position: "fixed", right: "20px", zIndex: 50000, top: "20px", fontSize: "30px", fontWeight: "600", textAlign: "center", }; for(i in style) { elm.style[i] = style[i]; } return elm; } function redisplayTime(elm) { elm.innerHTML = second_to_disp(timem()-_initialTime); } function autoupdate() { redisplayTime(_timerdiv); if(!_forcestop) { setTimeout(autoupdate, 30); } } var _timerdiv = adddiv(); var _initialTime = timem(); var _forcestop = false; autoupdate();