Advertisement
krishean

countdown.hta

Dec 20th, 2012
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.90 KB | None | 0 0
  1. <html>
  2. <head>
  3. <HTA:APPLICATION ID="oHTA"
  4.     APPLICATIONAME="myApp"
  5.     MAXIMIZEBUTTON="no"
  6.     SINGLEINSTANCE="yes"
  7.     BORDER="thin"
  8.     INNERBORDER="no">
  9. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  10. <title>Countdown</title>
  11. <script type="text/javascript">
  12. //<![CDATA[
  13. function e(id){return document.getElementById(id);}
  14. function addZeros(a,b){a=String(a);while(a.length<b)a='0'+a;return a;}
  15. var Countdown={
  16.     element: null,
  17.     intervalID: null,
  18.     utc: 0,
  19.     now: 0,
  20.     fps: 1,
  21.     init: function(el){
  22.         this.element = el;
  23.         this.utc = Math.floor(Date.UTC(2012, 11, 21, 11, 12, 0) / 1000);
  24.         this.now = dt2ts(new Date());
  25.         this.start();
  26.     },
  27.     update: function(){
  28.         this.now = dt2ts(new Date());
  29.         var sec = this.utc - this.now;
  30.         this.element.innerHTML = Math.abs(sec) == sec ? formatTime(sec) : 'World didn\'t end, too bad.';
  31.     },
  32.     start: function(){
  33.         if(!this.intervalID)this.intervalID = window.setInterval((function(self){
  34.             return function(){self.update();};
  35.         })(this), 1000 / this.fps);
  36.         this.update();
  37.     },
  38.     stop: function(){if(this.intervalID)window.clearInterval(this.intervalID);}
  39. };
  40. function dt2ts(dt){return Math.floor(dt.getTime()/1000);}
  41. function formatTime(s){
  42.     return addZeros(Math.floor(s / 3600), 2)+':'+
  43.         addZeros(Math.floor((s / 60) % 60), 2)+':'+
  44.         addZeros(Math.floor(s % 60), 2);
  45. }
  46. window.onload=function(){
  47.     var w=240,h=160;
  48.     window.resizeTo(w,h);
  49.     window.moveTo((screen.availWidth/2)-(w/2),(screen.availHeight/2)-(h/2));
  50.     document.oncontextmenu=function(){return false;};
  51.     document.body.onselectstart=function(){return false;};
  52.     Countdown.init(e('countdown'));
  53. };
  54. //]]>
  55. </script>
  56. <style type="text/css">
  57. /*<![CDATA[*/
  58. *{cursor:default;}
  59. body{overflow:auto;font:13px Tahoma;background-color:ButtonFace;}
  60. #page{margin-top:55px;text-align:center;}
  61. /*]]>*/
  62. </style>
  63. </head>
  64. <body>
  65.  
  66. <div id="page">
  67.     <div id="countdown">&nbsp;</div>
  68. </div>
  69.  
  70. </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement