file ongoing.html was added on branch MOODLE_15_STABLE on 2005-07-07 16:14:36 +0000
[moodle.git] / mod / quiz / timer.js
blobb02823286ce4a22806914e1d95616ce466e04fce
1 // $Id$
2 //
3 // QuizTimer
4 // Provides a counter that keeps track how much
5 // time user have left to check in started quiz.
6 //
7 function countdown_clock() {
8     var timeout_id = null;
9     quizTimerValue = quizTimerValue - 1;
11     if(quizTimerValue == 0) {
12         clearTimeout(timeout_id);
13         document.forms[0].timeup.value = 1;
14         document.forms[0].submit();
15     }
17     now = quizTimerValue;
18     var hours = Math.floor( now / 3600 );
19     parseInt(hours);
20     now = now - (hours * 3600);
21     var minutes = Math.floor(now / 60);
22     parseInt(minutes);
23     now = now - (minutes * 60);
24     var seconds = now;
25     parseInt(seconds);
27     var t = "" + hours;
28     t += ((minutes < 10) ? ":0" : ":") + minutes;
29     t += ((seconds < 10) ? ":0" : ":") + seconds;
30     window.status = t.toString();
32     if(hours == 0 && minutes == 0 && seconds <= 15) {
33         //go from fff0f0 to ffe0e0 to ffd0d0...ff2020, ff1010, ff0000 in 15 steps
34         var hexascii = "0123456789ABCDEF";
35         var col = 'ff' + hexascii.charAt(seconds) + '0' + hexascii.charAt(seconds) + 0;
36         changecolor(col);
37     }
38     document.forms['clock'].time.value = t.toString();
39     timeout_id = setTimeout("countdown_clock()", 1000);
42 function movecounter() {
44     var pos;
46     if (window.innerHeight) {
47         pos = window.pageYOffset
48     } else if (document.documentElement && document.documentElement.scrollTop) {
49         pos = document.documentElement.scrollTop
50     } else if (document.body) {
51           pos = document.body.scrollTop
52     }
54     if (pos < theTop) {
55         pos = theTop;
56     } else {
57         pos += 100;
58     }
59     if (pos == old) {
60         this.style.top = pos;
61     }
62     old = pos;
63     temp = setTimeout('movecounter()',100);
66 function getObjectById (name) {
68     if (document.getElementById) {
69         this.obj = document.getElementById(name);
70         this.style = document.getElementById(name).style;
71     } else if (document.all) {
72         this.obj = document.all[name];
73         this.style = document.all[name].style;
74     } else if (document.layers) {
75         this.obj = document.layers[name];
76         this.style = document.layers[name];
77     }