通過調用startclock();pauseclock();stopclock()來控制計時器開始計算與暫停,從新計時等操作。注意調用次數。
var timeSpan = 1000; //設置時間步長,
var mued = 0; //檢測鼠標多長時間爲移動
var DefaultDuration = 120; //默認定時保存時長
function clockon() {
LearningSeconds++;
thistime = LearningSeconds;
var hours = parseInt(thistime / 3600);
var minutes = parseInt((thistime - hours * 3600) / 60);
var seconds = parseInt(thistime % 60);
if (eval(hours) < 10) { hours = "0" + hours }
if (eval(minutes) < 10) { minutes = "0" + minutes }
if (seconds < 10) { seconds = "0" + seconds }
thistime = hours + ":" + minutes + ":" + seconds
if (document.all) {//火狐瀏覽器不執行
//bgclocknoshade.innerHTML = thistime
spTime.innerHTML = thistime
}
else {
$("#spTime").html(thistime);
}
mued++; //記錄鼠標爲移動時間
// var timer = setTimeout("clockon()", timeSpan);
if (mued >= 60) {//監控鼠標爲移動時間
//timeSpan = 10000;
//alert("好久沒有動了");
mark = true;
pauseclock();
}
else {
timeSpan = 1000;
}
//自動保存設置
//監控是否可以進入考覈//退回重做的必須重新學習
}
var se;
function startclock() { se = setInterval("clockon()", timeSpan); }
function pauseclock() { clearInterval(se); }
function stopclock() { clearInterval(se); ss = 1; }