home *** CD-ROM | disk | FTP | other *** search
/ Chip 2009 November / Chip_2009.11_CD.iso / Chip_WPI / WPIScripts / timers.js < prev    next >
Encoding:
JavaScript  |  2006-10-24  |  1.7 KB  |  94 lines

  1. //
  2. // Date Last Modified: Sunday, October 22, 2006
  3. //
  4. // Modified By: Mark Ritter (mritter)
  5. //
  6.  
  7.  
  8. function startInterval()
  9. {
  10.     position="timers.js";
  11.     whatfunc="startInterval()";
  12.  
  13.     if (Seconds<1)
  14.         Seconds=1;
  15.     startSecs=Seconds;
  16.     if (Seconds>3600) 
  17.         Seconds=3600;
  18.     if (Seconds>60)
  19.     {
  20.         m=parseInt(Seconds/60);
  21.         Seconds=Seconds-(m*60);
  22.     }
  23.     else 
  24.         m=0;
  25.     
  26.     interval = window.setInterval("tTimer()",1000);
  27. }
  28.  
  29.  
  30. function stopInterval()
  31. {
  32.     position="timers.js";
  33.     whatfunc="stopInterval()";
  34.  
  35.     if (interval != "")
  36.     {
  37.         window.clearInterval(interval);
  38.         interval="";
  39.  
  40. //        document.getElementById("TimerLayer").style.display = "none";
  41.         document.getElementById("TimerLayer").style.visibility = "hidden";
  42.     }
  43. }
  44.  
  45.  
  46. function tTimer()
  47. {
  48.     position="timers.js";
  49.     whatfunc="tTimer()";
  50.  
  51.     var txt="";
  52.  
  53.     if (Seconds==0) 
  54.         Seconds=1;
  55.  
  56.     txt = m+":"+ --Seconds;
  57.  
  58.     if (Seconds==0)
  59.     {
  60.         txt = m+":"+"0"+Seconds;
  61.         m--;
  62.         Seconds=60;
  63.     }
  64.  
  65.     if (Seconds<10 && Seconds>-1)  
  66.         txt = m+":"+"0"+Seconds;
  67.  
  68.     document.getElementById("TimerDisplay").innerHTML=txt;
  69.     passed++;
  70.  
  71.     document.getElementById("Timer_bar").style.width=Math.abs(TimerWidth-Math.floor((passed/startSecs)*TimerWidth))+"px";
  72.  
  73.     if (m==0 && Seconds<=StartBeepAtSecs)
  74.         PlaySound(wpipath+"\\Themes\\"+Theme+"\\TimerSound.wav");
  75.  
  76.     if (Seconds==60 && m<0)
  77.     {
  78.         document.getElementById("TimerDisplay").innerHTML="0:00";
  79.         document.getElementById("Timer_bar").width=0;
  80.         Pause(0,250);
  81.  
  82.         stopInterval();
  83.  
  84.         checkInstall('timer');
  85.     }
  86. }
  87.  
  88.  
  89. function PlaySound(soundfile)
  90. {
  91.     document.getElementById("TimerSound").src="";
  92.     document.getElementById("TimerSound").src=soundfile;
  93. }
  94.