Created
July 18, 2015 02:32
-
-
Save gffcoutinho/2577f2346b22095c5d10 to your computer and use it in GitHub Desktop.
This file contains 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 characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta http-equiv="x-ua-compatible" content="ie=9" /> | |
<title>Timer</title> | |
<HTA:APPLICATION | |
APPLICATIONNAME="Timer" | |
SCROLL="yes" | |
WINDOWSTATE="minimize" | |
SINGLEINSTANCE="yes" /> | |
<style> | |
#timer { font-size: 2em; } | |
</style> | |
</head> | |
<body onload="run()"> | |
<div> | |
<span id="timer"></span> | |
</div> | |
<script type="text/javascript"> | |
(function main( window, undefined ) { | |
var el = document.querySelector('title'); | |
var el2 = document.querySelector('#timer'); | |
var M = 60; | |
var fmt = function(sec) { | |
var min = Math.floor( sec / M ); | |
var rem = sec % M; | |
return min + ':' + ('0' + rem).substr( -2 ); | |
}; | |
var countDown = function( cnt, cb ) { | |
var id = window.setInterval(function() { | |
cnt = cnt - 1; | |
el.innerHTML = fmt( cnt ); | |
el2.innerHTML = fmt( cnt ); | |
if ( cnt < 1 ) { | |
window.clearInterval( id ); | |
cb(); | |
} | |
}, 1000); | |
}; | |
var showAlert = function( msg ) { | |
//window.focus(); | |
var sh = new ActiveXObject("WScript.Shell"); | |
//sh.Popup( msg ); | |
//sh.Run('mshta javascript:alert("' + msg + '");close();'); | |
sh.Run('cmd /c echo ' + msg + '&& pause', 1, true); | |
}; | |
function run() { | |
countDown( 25 * M, function() { | |
showAlert('work timer elapsed.'); | |
countDown( 5 * M, function() { | |
showAlert('recess timer elapsed.'); | |
window.close(); | |
}); | |
}); | |
}; | |
window.run = run; | |
})( window ); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment