Guest User

Untitled

a guest
Jul 11th, 2010
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Downloading...</title>
  4. </head>
  5. <body>
  6. <script type="text/javascript">
  7. // Description: displays the amount of time until the "dateFuture" entered below.
  8.  
  9. // NOTE: the month entered must be one less than current month. ie; 0=January, 11=December
  10. // NOTE: the hour is in 24 hour format. 0=12am, 15=3pm etc
  11. // format: dateFuture = new Date(year,month-1,day,hour,min,sec)
  12. // example: dateFuture = new Date(2003,03,26,14,15,00) = April 26, 2003 - 2:15:00 pm
  13.  
  14. var randomSecs=Math.floor(Math.random()*61);
  15. var randomMins=Math.floor(Math.random()*61);
  16. var randomHour=Math.floor(Math.random()*13)
  17.  
  18. dateFuture = new Date(2010,6,15,randomHour,randomMins,randomSecs);
  19.  
  20. // TESTING: comment out the line below to print out the "dateFuture" for testing purposes
  21. //document.write(dateFuture +"<br />");
  22.  
  23.  
  24. //###################################
  25. //nothing beyond this point
  26. function GetCount(){
  27.  
  28. dateNow = new Date(); //grab current date
  29. amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates
  30. delete dateNow;
  31.  
  32. // time is already past
  33. if(amount < 0){
  34. document.getElementById('countbox').innerHTML="File download complete. Grab from /recording.zip.";
  35. }
  36. // date is still good
  37. else{
  38. days=0;hours=0;mins=0;secs=0;out="";
  39.  
  40. amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
  41.  
  42. days=Math.floor(amount/86400);//days
  43. amount=amount%86400;
  44.  
  45. hours=Math.floor(amount/3600);//hours
  46. amount=amount%3600;
  47.  
  48. mins=Math.floor(amount/60);//minutes
  49. amount=amount%60;
  50.  
  51. secs=Math.floor(amount);//seconds
  52.  
  53. out+="Estimated download time remaining: ";
  54. if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
  55. if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}
  56. if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+" and ";}
  57. if(days != 0 || hours != 0 || mins != 0 || secs != 0){ out += secs +" seconds.<br>Refreshing the page may cause the download to restart.";}
  58. document.getElementById('countbox').innerHTML=out;
  59.  
  60. setTimeout("GetCount()", 1000);
  61. }
  62. }
  63.  
  64. window.onload=GetCount;//call when everything has loaded
  65.  
  66. </script>
  67. <div id="countbox"></div>
  68. </body>
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment