-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprueba.js
85 lines (77 loc) · 2.15 KB
/
prueba.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var theCount;
var alarm = document.getElementById("alarm");
var panel = document.getElementById("panel");
var turnOff = document.getElementById("turn-off");
var turnOffHor = document.getElementById("closing");
var detonate = document.getElementById("detonate");
alarm.volume = 0.50; //volume level
var time = document.getElementById("time");
function showCountDown() {
time.innerText = time.innerText - 1;
if (time.innerText == 0) {
clearInterval(theCount);
time.classList.add("crono");
abort.classList.add("hide");
detonate.classList.add("show");
setTimeout(function () {
turnOff.classList.add("close");
turnOffHor.classList.add("close");
reload.classList.add("show");
alarm.pause();
}, 1500);
}
}
var cover = document.getElementById("cover");
cover.addEventListener("click", function () {
if (this.className == "box") this.classList.add("opened");
else this.classList.remove("opened");
});
var btn = document.getElementById("activate");
activate.addEventListener("click", function () {
this.classList.add("pushed");
alarm.load();
alarm.currentTime = 10.1;
alarm.play();
setTimeout(function () {
panel.classList.add("show");
theCount = setInterval(showCountDown, 1000);
alarm.load();
alarm.play();
}, 500);
});
var abort = document.getElementById("abort");
abort.addEventListener("click", function () {
btn.classList.remove("pushed");
panel.classList.remove("show");
clearInterval(theCount);
time.innerText = 9;
alarm.pause();
alarm.currentTime = 10;
alarm.play();
});
var reload = document.getElementById("restart");
reload.addEventListener("click", function () {
panel.classList.remove("show");
turnOff.classList.remove("close");
turnOffHor.classList.remove("close");
abort.classList.remove("hide");
detonate.classList.remove("show");
cover.classList.remove("opened");
btn.classList.remove("pushed");
this.classList.remove("show");
time.classList.remove("crono");
time.innerText = 9;
});
setTimeout(function () {
cover.classList.remove("opened");
}, 100);
var mute = document.getElementById("mute");
mute.addEventListener("click", function () {
if (this.className == "muted") {
alarm.muted = false;
this.classList.remove("muted");
} else {
alarm.muted = true;
this.classList.add("muted");
}
});