From: Gavin L. v. a. <we...@ma...> - 2005-02-18 16:01:41
|
Log Message: ----------- Add javascript to gateway template file for active timer on gateway quizzes. Tags: ---- rel-2-1-a1 Modified Files: -------------- webwork2/conf/templates: gw.template Revision Data ------------- Index: gw.template =================================================================== RCS file: /webwork/cvs/system/webwork2/conf/templates/Attic/gw.template,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -Lconf/templates/gw.template -Lconf/templates/gw.template -u -r1.1.2.1 -r1.1.2.2 --- conf/templates/gw.template +++ conf/templates/gw.template @@ -148,7 +148,12 @@ /******************/ div.gwMessage { background-color:#dddddd; color: black; } -div.gwTiming { background-color:#ddddff; color: black; } +div.gwTiming { + background-color:#ddddff; + color: black; + margin-top: 10px; + margin-bottom: 0px; +} div.gwWarning { background-color:#ffffdd; color: black; } span.resultsWithError { background-color: #ffcccc; color: black; } @@ -167,7 +172,7 @@ /* background-color: #e0e0ff; */ background-color: transparent; color: black; -/* padding: 2px; */ +/* padding: 2px; */, /* border: dashed black 1px; */ } div.gwSoln b { color: navy; } @@ -195,15 +200,16 @@ </style> <script language="javascript" type="text/javascript"> -function jumpTo(ref) { +function jumpTo(ref) { // scrolling javascript functin if ( ref ) { + var pn = ref - 1; // we start anchors at 1, not zero if ( navigator.appName == "Netscape" && parseFloat(navigator.appVersion) < 5 ) { - var xpos = document.anchors[ref].x; - var ypos = document.anchors[ref].y; + var xpos = document.anchors[pn].x; + var ypos = document.anchors[pn].y; } else { - var xpos = document.anchors[ref].offsetLeft; - var ypos = document.anchors[ref].offsetTop; + var xpos = document.anchors[pn].offsetLeft; + var ypos = document.anchors[pn].offsetTop; } if ( window.scrollTo == null ) { // cover for anyone window.scroll(xpos,ypos); // lacking js1.2 @@ -213,9 +219,51 @@ } return false; // prevent link from being followed } + +// timer for gateway +var theTime = -1; // -1 before we've initialized + +function runtimer() { +// aesthetically this is displeasing: we're assuming that the +// ContentGenerator will put the appropriate form elements in that +// page for us to manipulate. even with error checking, it seems sort +// of odd. + if ( document.gwtimer == null ) { // no timer + return; + } else { + var tm = document.gwtimer.gwtime; + var st = document.gwtimer.gwpagetimeleft.value; + + if ( st == 0 ) { // no time limit + return; + } else { + if ( theTime == -1 ) { + theTime = st; + tm.value = toMinSec(theTime); + setTimeout("runtimer()", 1000); // 1000 ms = 1 sec + } else { + theTime--; + tm.value = toMinSec(theTime); + setTimeout("runtimer()", 1000); // 1000 ms = 1 sec + } + } + } +} +function toMinSec(t) { +// convert to min:sec + mn = Math.floor(t/60); + sc = t - 60*mn; + if ( mn < 10 && mn > -1 ) { + mn = "0" + mn; + } + if ( sc < 10 ) { + sc = "0" + sc; + } + return mn + ":" + sc; +} </script> </head> -<body> +<body onload="runtimer();"> <table width="100%" cellpadding="10" cellspacing="0" border="0"> <tr valign="top"> <!-- removed left sidebar --> |