/*///////////////////////////////////////////////////////// // This code is based off of // "Live Clock Lite" script - Version 1.0 // By Mark Plachetta (astroboy@zip.com.au) // // The original script displayed a clock. // Mark Nielsen modified it to be a countdown timer // for the lesson module in moodle. // // Below is the code that is used to call this page. // echo "\n"; // //////////////////////////////////////////////////////////*/ var myfont_face = "Arial"; var myfont_size = "12"; var myfont_color = "#000000"; var myback_color = "#FFFFFF"; var mywidth = 80; var my12_hour = 1; var stopclock = 0; var javatimeDate = new Date(); var javatime = javatimeDate.getTime(); javatime = Math.floor(javatime/1000); difference = javatime - servertime; starttime = starttime + difference; var dn = ""; var old = ""; if (document.all||document.getElementById) { document.write(''); } else if (document.layers) { document.write(''); } 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'); } leave();*/ function show_clock() { //show clock in NS 4 if (document.layers) document.ClockPosNS.visibility="show" if (old == "die") { return; } currentDate = new Date(); current = currentDate.getTime(); current = Math.floor(current/1000); if (current > starttime + testlength) { myclock = ''; myclock += ''; myclock += "Time is up"; myclock += ''; 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(); if (secs < 10) { secs = "0"+secs; } myclock = ''; myclock += ''; if (hours > 0) { myclock += hours+":"; if (minutes < 10) { minutes = "0"+minutes; } } myclock += minutes+":"+secs; myclock += ''; } if (old == "true") { document.write(myclock); old = "die"; return; } if (document.layers) { clockpos = document.ClockPosNS; liveclock = clockpos.document.LiveClockNS; liveclock.document.write(myclock); liveclock.document.close(); } else if (document.all) { LiveClockIE.innerHTML = myclock; } else if (document.getElementById) { document.getElementById("LiveClockIE").innerHTML = myclock; } if (stopclock == 0) { setTimeout("show_clock()",1000); } }