-
Notifications
You must be signed in to change notification settings - Fork 0
/
quiz.js
24 lines (23 loc) · 900 Bytes
/
quiz.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Quiz extension, https://github.com/GiovanniSalmeri/yellow-quiz
"use strict";
document.addEventListener("DOMContentLoaded", function() {
var t = document.getElementById('quiz-progresstext');
var b = document.getElementById('quiz-progressbar');
if (t) {
var availSecs = t.getAttribute('data-time')*60;
var secsLeft = availSecs;
setInterval (function() {
if (secsLeft >= 0) {
var min = ~~(secsLeft/60);
var sec = secsLeft%60;
var w = 100 - (secsLeft*100 / availSecs);
t.innerHTML = (min ? (min+' min') : '') + (sec ? (' '+sec+' s'): '') + ' ';
b.style.width = w + '%';
secsLeft--;
} else {
secsLeft = availSecs;
document.getElementById('quiz-form').submit();
}
}, 1000);
}
});