From 070515ce4277158a98d778ff9fc27d8fa708143f Mon Sep 17 00:00:00 2001 From: urs_hunkler Date: Sat, 22 Oct 2005 15:29:05 +0000 Subject: [PATCH] I reworked the timer JavaScript and the CSS properties. The floating of the timer now works in MSIE, Firefox and Opera the same way. The first correction was not sufficient. --- mod/quiz/jstimer.php | 15 ++++++--------- mod/quiz/styles.php | 11 ++++------- mod/quiz/timer.js | 35 +++++++++++++++-------------------- 3 files changed, 25 insertions(+), 36 deletions(-) diff --git a/mod/quiz/jstimer.php b/mod/quiz/jstimer.php index 031d38cf705..b88977fe907 100644 --- a/mod/quiz/jstimer.php +++ b/mod/quiz/jstimer.php @@ -15,7 +15,7 @@ parseInt(quizTimerValue); // --> -
+
@@ -39,17 +39,14 @@ parseInt(quizTimerValue); diff --git a/mod/quiz/styles.php b/mod/quiz/styles.php index 584676573c7..0fd0147eb71 100644 --- a/mod/quiz/styles.php +++ b/mod/quiz/styles.php @@ -48,10 +48,7 @@ body#mod-quiz-report table#itemanalysis .qname { width:150px } #mod-quiz-attempt #timer { - position:fixed !important; - top:100px !important; - left:10px !important -} -* html #mod-quiz-attempt #timer { - position:absolute !important -} + position:absolute; + /*top:100px; is set by js*/ + left:10px +} \ No newline at end of file diff --git a/mod/quiz/timer.js b/mod/quiz/timer.js index 4eccb250f26..7da33aeb681 100644 --- a/mod/quiz/timer.js +++ b/mod/quiz/timer.js @@ -4,7 +4,7 @@ // Provides a counter that keeps track how much // time user have left to check in started quiz. // -function countdown_clock() { +function countdown_clock(theTimer) { var timeout_id = null; quizTimerValue = quizTimerValue - 1; @@ -32,14 +32,14 @@ function countdown_clock() { if(hours == 0 && minutes == 0 && seconds <= 15) { //go from fff0f0 to ffe0e0 to ffd0d0...ff2020, ff1010, ff0000 in 15 steps var hexascii = "0123456789ABCDEF"; - var col = 'ff' + hexascii.charAt(seconds) + '0' + hexascii.charAt(seconds) + 0; - changecolor(col); + var col = '#' + 'ff' + hexascii.charAt(seconds) + '0' + hexascii.charAt(seconds) + 0; + theTimer.style.backgroundColor = col; } document.forms['clock'].time.value = t.toString(); - timeout_id = setTimeout("countdown_clock()", 1000); + timeout_id = setTimeout("countdown_clock(theTimer)", 1000); } -function movecounter() { +function movecounter(timerbox) { var pos; @@ -57,22 +57,17 @@ function movecounter() { pos += 100; } if (pos == old) { - this.style.top = pos; + timerbox.style.top = pos + 'px'; } old = pos; - temp = setTimeout('movecounter()',100); + temp = setTimeout('movecounter(timerbox)',100); } -function getObjectById (name) { - - if (document.getElementById) { - this.obj = document.getElementById(name); - this.style = document.getElementById(name).style; - } else if (document.all) { - this.obj = document.all[name]; - this.style = document.all[name].style; - } else if (document.layers) { - this.obj = document.layers[name]; - this.style = document.layers[name]; - } -} +function xGetElementById(e) +{ + if(typeof(e)!='string') return e; + if(document.getElementById) e=document.getElementById(e); + else if(document.all) e=document.all[e]; + else e=null; + return e; +} \ No newline at end of file