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.
This commit is contained in:
urs_hunkler
2005-10-22 15:29:05 +00:00
parent f77efbe3be
commit 070515ce42
3 changed files with 25 additions and 36 deletions
+6 -9
View File
@@ -15,7 +15,7 @@ parseInt(quizTimerValue);
// -->
</script>
<script language="javascript" type="text/javascript" src="timer.js"></script>
<div id="timer" style="position: absolute; top: 100; left: 10;">
<div id="timer">
<!--EDIT BELOW CODE TO YOUR OWN MENU-->
<table class="generalbox" border="0" cellpadding="0" cellspacing="0" width="150">
<tr>
@@ -39,17 +39,14 @@ parseInt(quizTimerValue);
</div>
<script language="javascript" type="text/javascript">
<!--
function changecolor(col) {
// Changes the timers background color
var d = document.getElementById('QuizTimer');
d.style.backgroundColor = col;
}
var timerbox = getObjectById('timer');
var timerbox = xGetElementById('timer');
var theTimer = xGetElementById('QuizTimer');
var theTop = 100;
var old = theTop;
movecounter(this);
document.onload = countdown_clock();
movecounter(timerbox);
document.onload = countdown_clock(theTimer);
// -->
</script>
+4 -7
View File
@@ -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
}
+15 -20
View File
@@ -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;
}