-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudyThis.js
More file actions
36 lines (34 loc) · 999 Bytes
/
studyThis.js
File metadata and controls
36 lines (34 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var start = document.getElementById("start"),
reset = document.getElementById("reset"),
stop = document.getElementById("stop"),
current_progress = 0,
step = 0.5; // the smaller this is the slower the progress bar
start.onclick = function () {
interval = setInterval(function () {
current_progress += step;
progress =
Math.round((Math.atan(current_progress) / (Math.PI / 2)) * 100 * 1000) /
1000;
$(".progress-bar")
.css("width", progress + "%")
.attr("aria-valuenow", progress)
.text(progress + "%");
if (progress >= 100) {
clearInterval(interval);
} else if (progress >= 70) {
step = 0.1;
}
}, 100);
};
stop.onClick = function () {
$(".progress-bar")
.css("width", "100%")
.attr("aria-valuenow", 100)
.text("100% Complete");
clearInterval(interval); // Important to stop the progress bar from increasing
};
/* Stop button */
reset.onclick = function () {
$(".progress-bar").css("width", "0%").attr("aria-valuenow", 0);
clearInterval(interval);
};