Permalink
Browse files

changed the math for calculating the time left in a lesson to be more…

… compatible with browsers
  • Loading branch information...
1 parent 5695336 commit 7f2ad6c2d3e5cc114919099abd3c8129595cd56d michaelpenne committed Mar 11, 2005
Showing with 15 additions and 9 deletions.
  1. +15 −9 mod/lesson/timer.js
View
@@ -25,19 +25,25 @@
var mywidth = 80;
var my12_hour = 1;
var stopclock = 0;
-
+ var myclock = '';
+ var timeleft, hours, minutes, secs;
var javatimeDate = new Date();
var javatime = javatimeDate.getTime();
javatime = Math.floor(javatime/1000);
difference = javatime - servertime;
starttime = starttime + difference;
- var dn = ""; var old = "";
+ var dn = "";
+ var old = "";
- if (document.all||document.getElementById) { document.write('<span id="LiveClockIE" style="width:'+mywidth+'px;"></span>'); }
- else if (document.layers) { document.write('<ilayer id="ClockPosNS"><layer width="'+mywidth+'" id="LiveClockNS"></layer></ilayer>'); }
- else { old = "true"; show_clock(); }
+ if (document.all||document.getElementById) {
+ document.write('<span id="LiveClockIE" style="width:'+mywidth+'px;"></span>');
+ } else if (document.layers) {
+ document.write('<ilayer id="ClockPosNS"><layer width="'+mywidth+'" id="LiveClockNS"></layer></ilayer>');
+ } else {
+ old = "true"; show_clock();
+ }
/*function leave() { // feable attempt to run a script when someone leaves a timed test early, failed so far
window.onunload = window.open('http://www.google.com','','toolbar=no,menubar=no,location=no,height=500,width=500');
@@ -63,10 +69,10 @@
stopclock = 1;
} else {
timeleft = starttime + testlength - current;
- dateobj = new Date(null, null, null, null, null, timeleft, null);
- hours = dateobj.getHours();
- minutes = dateobj.getMinutes();
- secs = dateobj.getSeconds();
+ hours = Math.floor(timeleft/3600);
+ timeleft = timeleft - (hours * 3600);
+ minutes = Math.floor(timeleft/60);
+ secs = timeleft - (minutes * 60);
if (secs < 10) {
secs = "0"+secs;

0 comments on commit 7f2ad6c

Please sign in to comment.