-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
72 lines (61 loc) · 2.24 KB
/
script.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
let item = document.getElementsByClassName("item")
function purchase(pizzaIndex) {
// let body = document.getElementsByTagName("body")[0]
// body.style.filter = "blur(5px)";
document.getElementsByClassName("backdrop")[0].style.zIndex = 10;
let pizza = item[pizzaIndex]
let pizzaImage = pizza.getElementsByTagName("img")[0].src
document.getElementById("orderedPizza").src = pizzaImage
let overlay = document.getElementsByClassName("overlay")[0];
overlay.classList.remove("hidden");
console.log("clicked")
let cancel = document.getElementById("cancel")
console.log(cancel)
cancel.addEventListener("click", close)
document.getElementsByClassName("confirm")[0].addEventListener('click',confirm);
}
function close() {
let overlay = document.getElementsByClassName("overlay")[0];
overlay.classList.add("hidden");
document.getElementsByClassName("backdrop")[0].style.zIndex = -10;
console.log("cancel")
}
function confirm(){
close()
document.getElementsByClassName("backdrop")[2].style.zIndex = 10;
let overlay = document.getElementsByClassName("overlay")[2];
overlay.classList.remove("hidden");
console.log("confirm")
setInterval(updateTimer, 1000)
}
function orderClose(){
let overlay = document.getElementsByClassName("overlay")[2];
overlay.classList.add("hidden");
document.getElementsByClassName("backdrop")[2].style.zIndex = -10;
console.log("cancel")
}
function addTopping(){
document.getElementsByClassName("backdrop")[1].style.zIndex = 10;
let overlay = document.getElementsByClassName("overlay")[1];
overlay.classList.remove("hidden");
console.log("clicked")
}
function confirmTopping(){
let overlay = document.getElementsByClassName("overlay")[1];
overlay.classList.add("hidden");
document.getElementsByClassName("backdrop")[0].style.zIndex = -10;
}
let time = 45 * 60;
function updateTimer() {
let minutes = Math.floor(time / 60);
let seconds = time % 60;
minutes = minutes < 10 ? '0' + minutes : minutes;
seconds = seconds < 10 ? '0' + seconds : seconds;
document.getElementById('timer').textContent = `${minutes}:${seconds}`;
if (time > 0) {
time--;
} else {
clearInterval(timerInterval);
alert("Time's up!");
}
}