JavaScript
1
Вклад в тег
function updateExamTimer() {
var timeLeft = EXAM_TIME_LEFT - elapsedTime;
elapsedTime += 1;
var minutes = Math.floor(timeLeft / 60);
var seconds = timeLeft % 60;
var hours = Math.floor(minutes / 60);
var minutes = minutes % 60;
if (hours < 10) { hours = '0' + hours; }
if (minutes < 10) { minutes = '0' + minutes; }
if (seconds < 10) { seconds = '0' + seconds; }
if (timeLeft <= 0) {
alert('Sizning imtihon topshirish muddatingiz yakunlandi.');
// If we're in ajax mode, submit via ajax - otherwise, redirect to the completion page
if (jQuery('#exam-ui').length) {
finishExam(false);
} else {
document.location.href = 'complete.php?id=' + EXAM_REQUEST_ID;
}
} else {
jQuery('#exam-time-left').val(hours + ':' + minutes + ':' + seconds);
if(navigator.onLine) {
// Устройство в интернете
setTimeout('updateExamTimer()', 1000);
} else {
// Устройство не подключено к интернету
}
}
}