-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlunch.html
More file actions
590 lines (478 loc) 路 16.5 KB
/
Copy pathlunch.html
File metadata and controls
590 lines (478 loc) 路 16.5 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css" integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<title>Lunch | TAS</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
</head>
<body>
<img src="/assets/images/food.png" alt="" srcset="">
<main>
<header>
<p>
<a href="attendence.html" title="Attendance" class="arrow"><i class="fa-solid fa-arrow-left"></i></a>
Lunch
</p>
<p>
<a href="login.html" title="Login" ><i class="fa-solid fa-mountain-sun" id="linkI" ></i></a>
<a href="breakm.html" title="Break Morning" ><i class="fa-solid fa-mug-hot" id="linkI" ></i></a>
<a href="breake.html" title="Break Evening" ><i class="fa-solid fa-glass-water" id="linkI" ></i></a>
</p>
</header>
<section id="entriesSection" class="entry-container">
</section>
<h6>
<button id="clear" onclick="confirmClearEntries()" disabled >Clear Data</button>
<button id="download" disabled>Download Entries</button>
</h6>
</main>
</body>
<script>
function loadEntries() {
const sectionMap = {
"login.html": "Login",
"breakm.html": "Break-Morning",
"lunch.html": "Lunch",
"breake.html": "Break-Evening"
};
const currentSection = sectionMap[window.location.pathname.split("/").pop()];
const entries = JSON.parse(localStorage.getItem(currentSection)) || [];
const entryContainer = document.getElementById("entriesSection");
entryContainer.innerHTML = ''; // Clear existing entries before adding new ones
entries.forEach((entry) => {
const entryDiv = document.createElement("article");
entryDiv.className = "entry";
const nameElement = document.createElement("h1");
nameElement.textContent = entry.name;
const timeSpan = document.createElement("span");
timeSpan.textContent = entry.time;
const departmentElement = document.createElement("h2");
departmentElement.textContent = entry.department;
const informationElement = document.createElement("h3");
informationElement.textContent = entry.information;
const reasonElement = document.createElement("h4");
reasonElement.textContent = entry.reason;
const spaceElement = document.createElement("span");
spaceElement.textContent = '';
entryDiv.appendChild(nameElement);
entryDiv.appendChild(timeSpan);
entryDiv.appendChild(departmentElement);
entryDiv.appendChild(informationElement);
entryDiv.appendChild(reasonElement);
// entryDiv.appendChild(spaceElement);
// Create buttons for "Morning Break", "Lunch", "Evening Break"
// const morningBreakButton = createBreakButton("Morning Break", entryDiv);
// const lunchButton = createBreakButton("Lunch", entryDiv);
// const eveningBreakButton = createBreakButton("Evening Break", entryDiv);
// entryDiv.appendChild(morningBreakButton);
// entryDiv.appendChild(lunchButton);
// entryDiv.appendChild(eveningBreakButton);
entryContainer.appendChild(entryDiv);
});
updateButtonStates(entries);
}
function createBreakButton(buttonText, entryDiv) {
const button = document.createElement("button");
button.textContent = buttonText;
const startTimeSpan = document.createElement("h4");
// const endTimeSpan = document.createElement("h4");
entryDiv.appendChild(startTimeSpan);
let clickCount = 0;
let startTime;
button.onclick = function() {
clickCount++;
if (clickCount === 1) {
// First click: record the start time
startTime = new Date();
startTimeSpan.textContent = ` ${formatTime(startTime)} to `;
// one = startTimeSpan.textContent;
button.textContent = "End Break";
} else if (clickCount === 2) {
// Second click: record the end time and disable the button
const endTime = new Date();
startTimeSpan.textContent = `${formatTime(startTime)} to ${formatTime(endTime)}`;
button.disabled = true; // Disable the button after the second click
// Save the times to local storage
saveBreakTimes(buttonText, startTime, endTime);
}
};
return button;
}
function saveBreakTimes(breakType, startTime, endTime) {
const sectionMap = {
"login.html": "Login",
"breakm.html": "Break-Morning",
"lunch.html": "Lunch",
"breake.html": "Break-Evening"
};
const currentPage = window.location.pathname.split("/").pop();
const currentSection = sectionMap[currentPage];
// Retrieve existing entries from localStorage
const entries = JSON.parse(localStorage.getItem(currentSection)) || [];
// Create a new entry for the break times
// const newEntry = {
// name: "Example Name", // Replace with actual name or logic
// time: `${formatTime(startTime)} to ${formatTime(endTime)}`,
// department: "Example Department", // Replace with actual department or logic
// information: "Example Information", // Replace with actual information or logic
// reason: breakType
// };
// Add the new entry to the list
entries.push(newEntry);
// Save updated entries back to localStorage
localStorage.setItem(currentSection, JSON.stringify(entries));
// Update button states
updateButtonStates(entries);
}
function formatTime(date) {
// Helper function to format time as "HH:mm"
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });
}
// Update button states (assuming you have a mechanism to call this as needed)
function updateButtonStates(entries) {
const clearButton = document.getElementById("clear");
const downloadButton = document.getElementById("download");
// Check if there are any entries
const hasEntries = entries.length > 0;
// Enable or disable buttons based on the presence of entries
clearButton.disabled = !hasEntries;
downloadButton.disabled = !hasEntries;
}
// Load entries on page load
window.onload = function () {
loadEntries();
};
function confirmClearEntries() {
if (confirm("Are you sure you want to delete all entries for this section?")) {
clearEntries();
}
}
function clearEntries() {
const sectionMap = {
"login.html": "Login",
"breakm.html": "Break-Morning",
"lunch.html": "Lunch",
"breake.html": "Break-Evening"
};
const currentPage = window.location.pathname.split("/").pop();
const currentSection = sectionMap[currentPage];
// Clear the specific section's entries from localStorage
localStorage.removeItem(currentSection);
// Reset the entry container
document.getElementById("entriesSection").innerHTML = '';
// Update button states after clearing entries
updateButtonStates([]);
}
function confirmClearEntries() {
if (confirm("Are you sure you want to delete all entries for this section?")) {
clearEntries();
}
}
function clearEntries() {
const sectionMap = {
"login.html": "Login",
"breakm.html": "Break-Morning",
"lunch.html": "Lunch",
"breake.html": "Break-Evening"
};
const currentPage = window.location.pathname.split("/").pop();
const currentSection = sectionMap[currentPage];
// Clear the specific section's entries from localStorage
localStorage.removeItem(currentSection);
// Reset the entry container
document.getElementById("entriesSection").innerHTML = '';
// Update button states after clearing entries
updateButtonStates([]);
}
function updateButtonStates(entries) {
const clearButton = document.getElementById("clear");
const downloadButton = document.getElementById("download");
// Check if there are any entries
const hasEntries = entries.length > 0;
// Enable or disable buttons based on the presence of entries
clearButton.disabled = !hasEntries;
downloadButton.disabled = !hasEntries;
}
// Load entries on page load
window.onload = function () {
loadEntries();
};
function exportToExcel() {
const sectionMap = {
"login.html": "Login",
"breakm.html": "Break-Morning",
"lunch.html": "Lunch",
"breake.html": "Break-Evening"
};
const currentPage = window.location.pathname.split("/").pop();
const currentSection = sectionMap[currentPage];
const entries = JSON.parse(localStorage.getItem(currentSection)) || [];
if (entries.length === 0) {
alert("No data available to download.");
return;
}
// Create a new workbook
const workbook = XLSX.utils.book_new();
const worksheet = XLSX.utils.json_to_sheet(entries);
// Add worksheet to workbook
XLSX.utils.book_append_sheet(workbook, worksheet, currentSection);
// Generate and download the Excel file
const dateTime = getCurrentDateTime();
XLSX.writeFile(workbook, `${currentSection}_${dateTime}.xlsx`);
}
function getCurrentDateTime() {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0'); // months are zero-indexed
const day = String(now.getDate()).padStart(2, '0');
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day}_${hours}-${minutes}-${seconds}`;
}
// Example: Call this function on a button click to download entries as XLSX
document.getElementById('download').addEventListener('click', exportToExcel);
</script>
</html>
<style>
@font-face {
font-family: Newake;
src: url(./assets/fonts/CreatoDisplay-Black.otf);
}
@font-face {
font-family: creato;
src: url(./assets/fonts/CreatoDisplay-Medium.otf);
}
img{
width: 60vw;
position: absolute;
top: 20%;
left: 50%;
transform: translateX(-50%);
}
body{
background: #FBF6EE;
}
main{
display: flex;
flex-direction: column;
position: relative;
justify-content: center;
padding: 40px;
}
header{
font-size: 30px;
text-align: center;
font-family: Newake;
display: flex;
justify-content: space-between;
}
.fa-arrow-left{
size: 10;
/* border: 1px solid black; */
padding: 3px 5px;
border-radius: 50%;
margin-right: 10px;
}
.arrow{
margin: 5px;
padding: 0px;
}
p{
margin: 0;
/* border: 2px solid black; */
display: flex;
}
a{
text-decoration: none;
color: #00000080;
font-size: 20px;
font-weight: 600;
font-family: creato;
margin-right: 20px;
/* display: block; */
}
a:hover{
color: #000000;
/* transition: ease-out 0.5s; */
}
section{
/* border: 2px solid black; */
margin-top: 30px;
display: grid;
grid-template-columns: repeat(2, 0fr);
justify-content: space-between;
}
article{
/* background-color: #9F70FD; */
/* background-color: #FEFF86; */
background-color: #9CF196;
/* background-color: #FFB0FE; */
padding: 30px;
width: 40vw;
display: grid;
margin-bottom: 30px;
grid-template-columns: auto auto;
box-shadow: 7px 7px 0px black;
}
h1, h2, h3, h4, span{
font-family: creato;
line-height: 0.5;
font-weight: 600;
font-size: 16px;
/* border: 1px solid black; */
}
h1, h2, h4{
grid-column-start: 1;
grid-column-end: 2;
/* border: 2px solid black; */
width: 400px;
}
span{
margin-top: 10px;
text-align: end;
/* border: 2px solid black; */
padding: 13px 30px 10px 30px;
width: min-content;
color: #000000;
font-weight: 500;
border-radius: 10px;
margin-left: 40px;
background-color: #FBF6EE;
}
h4{
margin-top: 10px;
/* text-align: end; */
}
h3{
text-align: center;
margin-left: 40px;
/* margin-right: 30px; */
/* margin-left: -200px; */
}
#clear, #download{
background-color: #000000;
padding: 20px 20px;
width: 150px;
color: white;
border-radius: 20px;
border: none;
outline: none;
font-family: creato;
cursor: pointer;
/* margin-left: 50%; */
margin-top: 20px;
/* transform: translateX(-50%); */
}
#download:disabled{
background-color: #00000070;
cursor: not-allowed;
}
#clear:disabled{
background-color: #FF000070;
cursor: not-allowed;
}
#clear{
background-color: #FF0000;
margin-right: 20px;
}
button{
background-color: #ffffff;
padding: 10px 5px;
width: 100px;
color: black;
border-radius: 20px;
border: none;
outline: none;
font-family: creato;
cursor: pointer;
/* margin-left: 50%; */
margin-top: 20px;
/* transform: translateX(-50%); */
}
button:disabled{
cursor: not-allowed;
}
h6{
display: flex;
justify-content: center;
}
@media (max-width: 768px) {
section{
display: flex;
flex-direction: column;
/* justify-content: center; */
align-items: center;
}
article{
width: 80vw;
}
span{
margin-left: 10vw;
}
img{
top: 30%;
}
}
@media (max-width: 425px) {
header{
margin-left: -50px;
}
.fa-arrow-left{
margin-right: 0px;
}
#likP{
margin-left: 200px;
}
span{
margin-left: 10vw;
}
h1, h2, h4{
/* grid-column-start: 1; */
/* grid-column-end: 2; */
/* border: 2px solid black; */
width: 170px;
}
button{
margin-left: 20px;
}
img{
top: 40%;
}
}
@media (max-width: 320px) {
p{
font-size: 24px;
}
#likP{
margin-left: 140px;
}
a{
margin-right: 5px;
scale: 0.8;
}
article{
width: 70vw;
}
span{
margin-left: 20vw;
}
button{
font-size: 10px;
padding: 10px 0px;
width: 90px;
margin-left: 20px;
}
h1, h2, h4{
/* grid-column-start: 1; */
/* grid-column-end: 2; */
/* border: 2px solid black; */
width: 100px;
}
img{
width: 80vw;
}
}
</style>