-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
87 lines (73 loc) · 1.87 KB
/
index.html
File metadata and controls
87 lines (73 loc) · 1.87 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
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
85
86
87
<!DOCTYPE html>
<html>
<head>
<title>Time Tracker</title>
<style>
body {
font-family: Arial;
text-align: center;
margin-top: 100px;
}
button {
padding: 10px 20px;
margin: 10px;
font-size: 16px;
cursor: pointer;
}
select {
padding: 8px;
font-size: 16px;
}
#status {
margin-top: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<h2>Employee Time Tracker</h2>
<select id="name" onchange="checkStatus()">
<option value="Jaweria Tariq">Jaweria Tariq</option>
<option value="Muteeb Raza">Muteeb Raza</option>
</select>
<br><br>
<button onclick="sendData('start')">Start Time</button>
<button onclick="sendData('end')">End Time</button>
<p id="status">Checking status...</p>
<script>
const scriptURL = "https://script.google.com/macros/s/AKfycbwHZyGMbTPgGOL09ooDA3Fv34_9VrEWhOHqRX9fqtxDopRSCd6jZe2J2Mwbvbpq3Shn/exec";
function sendData(action) {
const name = document.getElementById("name").value;
fetch(scriptURL, {
method: "POST",
body: JSON.stringify({ name: name, action: action })
})
.then(res => res.text())
.then(response => {
if (response === "ALREADY_STARTED") {
setStatus(name + " is already clocked IN");
}
else if (response === "NOT_STARTED") {
setStatus(name + " has not started yet");
}
else if (response === "STARTED") {
setStatus(name + " clocked IN");
}
else if (response === "ENDED") {
setStatus(name + " clocked OUT");
}
else {
setStatus("Error occurred");
}
})
.catch(() => setStatus("Connection error"));
}
function setStatus(msg) {
document.getElementById("status").innerText = msg;
}
function checkStatus() {
setStatus("Ready");
}
</script>
</body>
</html>