-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionality.js
More file actions
35 lines (33 loc) · 1.28 KB
/
Copy pathfunctionality.js
File metadata and controls
35 lines (33 loc) · 1.28 KB
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
document.addEventListener("DOMContentLoaded", function () {
lunch_clicked = 0;
clock_clicked = 0;
const lunchButton = document.getElementById("lunch_in");
const clockButton = document.getElementById("clock_in");
if (lunchButton && clockButton) {
console.log("buttons exist");
} else {
console.log("buttons don't exist");
}
document.querySelector("#lunch_in").addEventListener("click", function () {
console.log("lunch clicked!");
if (lunch_clicked % 2 == 0) {
alert("You are now clocked out for lunch");
document.querySelector("#lunch_in").textContent = "Lunch End";
} else {
alert("You are now clocked back in");
document.querySelector("#lunch_in").textContent = "Lunch Start";
}
lunch_clicked++;
});
document.querySelector("#clock_in").addEventListener("click", function () {
console.log("clock clicked!");
if (clock_clicked % 2 == 0) {
alert("You are now clocked out");
document.querySelector("#clock_in").textContent = "Clock Out";
} else {
alert("You are now clocked back in");
document.querySelector("#clock_in").textContent = "Clock In";
}
clock_clicked++;
});
});