通过调用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; }