| 1 |
var timerID = null;
|
| 2 |
var timerRunning = false;
|
| 3 |
var startDate;
|
| 4 |
var startSecs;
|
| 5 |
|
| 6 |
function stopclock() {
|
| 7 |
if(timerRunning) {
|
| 8 |
clearTimeout(timerID);
|
| 9 |
}
|
| 10 |
timerRunning = false;
|
| 11 |
}
|
| 12 |
|
| 13 |
function startclock() {
|
| 14 |
if(timerRunning == false) {
|
| 15 |
startDate = new Date();
|
| 16 |
startSecs = (startDate.getHours()*60*60) + (startDate.getMinutes()*60) + startDate.getSeconds();
|
| 17 |
}
|
| 18 |
|
| 19 |
stopclock();
|
| 20 |
showtime();
|
| 21 |
}
|
| 22 |
|
| 23 |
function showtime() {
|
| 24 |
var now = new Date();
|
| 25 |
var nowSecs = (now.getHours()*60*60) + (now.getMinutes()*60) + now.getSeconds();
|
| 26 |
var elapsedSecs = nowSecs - startSecs;;
|
| 27 |
|
| 28 |
var hours = Math.floor( elapsedSecs / 3600 );
|
| 29 |
elapsedSecs = elapsedSecs - (hours*3600);
|
| 30 |
|
| 31 |
var minutes = Math.floor( elapsedSecs / 60 );
|
| 32 |
elapsedSecs = elapsedSecs - (minutes*60);
|
| 33 |
|
| 34 |
var seconds = elapsedSecs;
|
| 35 |
|
| 36 |
var timeValue = "" + hours;
|
| 37 |
timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
|
| 38 |
timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
|
| 39 |
|
| 40 |
document.dpistudy.js_timer.value = timeValue;
|
| 41 |
timerID = setTimeout("showtime()",1000);
|
| 42 |
timerRunning = true;
|
| 43 |
}
|
| 44 |
|
| 45 |
function dpistudy_q5(center) {
|
| 46 |
stopclock();
|
| 47 |
document.dpistudy.instruct_q5.value = center;
|
| 48 |
document.dpistudy.submit();
|
| 49 |
}
|