-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.js
713 lines (686 loc) · 24.7 KB
/
code.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
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
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
//Global selections and variables
const todoInput = document.querySelector(".todo-input");
const todoInputBtn = document.querySelector(".btn-input");
const todoDays = document.querySelectorAll(".week");
const todoDaysCanvas = document.querySelectorAll(".todo-canva");
const daySelected = document.querySelector(".day-selected");
const targetday = document.querySelectorAll(".target-day");
const taskNum = document.querySelectorAll(".task-num");
const todoItem = document.querySelectorAll(".todo-container");
const topBarDaySelector = document.querySelector(".day-selector-container");
const timerPopup = document.querySelector(".timer-popup-container");
const timerCloseBtn = document.querySelector(".close-popup-btn");
const timerElement = document.querySelector("[data-timer-countdown2]");
const sideBarTimer = document.querySelector("[data-timer-countdown1]");
const timerStartStopBtn = document.querySelector("[data-start-stop-btn]");
const timerStartStopSidebarBtn = document.querySelector("[data-start-stop-sidebar-btn");
const filterTasksBtn = document.querySelector(".select-todo");
const burgerMenuBtn = document.querySelector(".hamburger-menu");
const sideBar = document.querySelector(".side-bar");
const burgerRow = document.querySelectorAll(".row");
//days of the week selectors
const sunday = document.querySelector(".sunday");
const monday = document.querySelector(".monday");
const tuesday = document.querySelector(".tuesday");
const wednesday = document.querySelector(".wednesday");
const thursday = document.querySelector(".thursday");
const friday = document.querySelector(".friday");
const saturday = document.querySelector(".saturday");
const day1 = document.querySelector(".day1");
const day2 = document.querySelector(".day2");
const day3 = document.querySelector(".day3");
const day4 = document.querySelector(".day4");
const day5 = document.querySelector(".day5");
const day6 = document.querySelector(".day6");
const day7 = document.querySelector(".day7");
//Event listeners
document.addEventListener("DOMContentLoaded", getLocalTasks);
todoInputBtn.addEventListener("click", addTodoItem);
sunday.addEventListener("click", openSunday);
monday.addEventListener("click", openMonday);
tuesday.addEventListener("click", openTuesday);
wednesday.addEventListener("click", openWednensday);
thursday.addEventListener("click", openThursday);
friday.addEventListener("click", openFriday);
saturday.addEventListener("click", openSaturday);
topBarDaySelector.addEventListener("click", daySelector);
timerCloseBtn.addEventListener("click", closeTimerPopup);
filterTasksBtn.addEventListener("click", filterTasks);
burgerMenuBtn.addEventListener("click", function () {
sideBar.classList.toggle("active");
burgerRow.forEach((row) => {
row.classList.toggle("active");
});
});
//event listener to start and stop timer
let startingTime = 25;
let time = startingTime * 60;
let timeInterval = -1;
timerStartStopBtn.addEventListener("click", startStopTimer);
timerStartStopSidebarBtn.addEventListener("click", startStopTimer);
//deleteItem event listeners for each day
day1.addEventListener("click", tasksFunctions);
day2.addEventListener("click", tasksFunctions);
day3.addEventListener("click", tasksFunctions);
day4.addEventListener("click", tasksFunctions);
day5.addEventListener("click", tasksFunctions);
day6.addEventListener("click", tasksFunctions);
day7.addEventListener("click", tasksFunctions);
//Functions
function startStopTimer() {
if (timeInterval == -1) {
timeInterval = setInterval(function () {
const minutes = Math.floor(time / 60);
let seconds = time % 60;
seconds = seconds < 10 ? "0" + seconds : seconds;
timerElement.innerHTML = `${minutes}:${seconds}`;
sideBarTimer.innerHTML = `${minutes}:${seconds}`;
time--;
time = time < 0 ? 0 : time;
if (timerElement.innerText == "0:00") {
timerElement.innerText = "Start Pomodoro";
sideBarTimer.innerText = "0:00";
timerStartStopBtn.innerText = "Start Again";
timerStartStopSidebarBtn.innerText = "Start Again";
timerStartStopBtn.style.backgroundColor = "#393e46";
timerStartStopSidebarBtn.style.backgroundColor = "#eeeeee";
timerStartStopSidebarBtn.style.color = "#000";
clearInterval(timeInterval);
timeInterval = -1;
time = startingTime * 60;
}
}, 1000);
timerStartStopBtn.innerText = "Stop";
timerStartStopSidebarBtn.innerText = "Stop";
timerStartStopBtn.style.backgroundColor = "#00adb5";
timerStartStopSidebarBtn.style.backgroundColor = "#00adb5";
timerStartStopBtn.style.color = "#fff";
timerStartStopSidebarBtn.style.color = "#fff";
} else {
clearInterval(timeInterval);
timeInterval = -1;
time = startingTime * 60;
timerElement.innerText = "Start Pomodoro";
sideBarTimer.innerText = "25:00";
timerStartStopBtn.innerText = "Start";
timerStartStopSidebarBtn.innerText = "Start";
timerStartStopBtn.style.backgroundColor = "#393e46";
timerStartStopSidebarBtn.style.backgroundColor = "#eeeeee";
timerStartStopSidebarBtn.style.color = "#000";
}
}
function addTodoItem(e) {
//prevent btn from reseting page
e.preventDefault();
//if statement to avoid the input of empty tasks
if (todoInput.value.length != 0) {
const divItem = document.createElement("div");
divItem.classList.add("todo-container");
//adding classes to identify different day's tasks
const newItem = document.createElement("li");
newItem.innerText = todoInput.value;
newItem.classList.add("todo-item");
//Check mark button
const completedBtn = document.createElement("button");
completedBtn.innerHTML = "<i class='fas fa-check'></i>";
completedBtn.classList.add("completed-btn");
//Trash button
const trashBtn = document.createElement("button");
trashBtn.innerHTML = "<i class='fas fa-trash-alt'></i>";
trashBtn.classList.add("trash-btn");
const timerBtn = document.createElement("button");
timerBtn.innerHTML = "<i class='fas fa-clock'></i>";
timerBtn.classList.add("timer-btn");
//this appends the input to the active day in the app
divItem.appendChild(newItem);
//Add task to local storage
saveLocalTasks(todoInput.value);
divItem.appendChild(completedBtn);
divItem.appendChild(trashBtn);
divItem.appendChild(timerBtn);
todoDaysCanvas.forEach((day) => {
if (day.classList.contains("active")) {
day.appendChild(divItem);
}
});
// Updates the tasks quantity num on sidebar
for (let i = 0; i < todoDays.length; i++) {
if (todoDays[i].classList.contains("active")) {
taskNum[i].innerText++;
}
}
todoInput.value = "";
} else {
alert("Add some text before adding your task");
}
}
//checks for which day is active, and checks when user clicks on diferent day and performs the change
function checkForActiveDay() {
for (let i = 0; i < todoDaysCanvas.length; i++) {
if (todoDaysCanvas[i].classList.contains("active") && todoDays[i].classList.contains("active")) {
todoDaysCanvas[i].classList.remove("active");
todoDays[i].classList.remove("active");
}
}
}
//focus on input when loading page
function FocusOnInput() {
todoInput.focus();
}
function openSunday() {
checkForActiveDay();
daySelected.innerText = "Sunday";
day1.classList.add("active");
sunday.classList.add("active");
}
function openMonday() {
checkForActiveDay();
daySelected.innerText = "Monday";
day2.classList.add("active");
monday.classList.add("active");
}
function openTuesday() {
checkForActiveDay();
daySelected.innerText = "Tuesday";
day3.classList.add("active");
tuesday.classList.add("active");
}
function openWednensday() {
checkForActiveDay();
daySelected.innerText = "Wednesday";
day4.classList.add("active");
wednesday.classList.add("active");
}
function openThursday() {
checkForActiveDay();
daySelected.innerText = "Thursday";
day5.classList.add("active");
thursday.classList.add("active");
}
function openFriday() {
checkForActiveDay();
daySelected.innerText = "Friday";
day6.classList.add("active");
friday.classList.add("active");
}
function openSaturday() {
checkForActiveDay();
daySelected.innerText = "Saturday";
day7.classList.add("active");
saturday.classList.add("active");
}
//Delete task items, mark task items as completed and timer
function tasksFunctions(e) {
let item = e.target;
if (item.classList[0] === "trash-btn") {
const deleteItem = item.parentElement;
removeLocalTasks(deleteItem);
deleteItem.remove();
for (let i = 0; i < todoDays.length; i++) {
if (todoDays[i].classList.contains("active")) {
taskNum[i].innerText--;
}
}
} else if (item.classList[0] === "completed-btn") {
const completedItem = item.parentElement;
completedItem.classList.toggle("completed");
} else if (item.classList[0] === "timer-btn") {
timerPopup.classList.add("active");
}
}
//close timer window
function closeTimerPopup() {
timerPopup.classList.remove("active");
}
//day selector with topbar arrows
function daySelector(e) {
let item = e.target;
if (item.classList[0] === "backwards-selector") {
if (day7.classList.contains("active")) {
checkForActiveDay();
openFriday();
} else if (day6.classList.contains("active")) {
checkForActiveDay();
openThursday();
} else if (day5.classList.contains("active")) {
checkForActiveDay();
openWednensday();
} else if (day4.classList.contains("active")) {
checkForActiveDay();
openTuesday();
} else if (day3.classList.contains("active")) {
checkForActiveDay();
openMonday();
} else if (day2.classList.contains("active")) {
checkForActiveDay();
openSunday();
} else {
checkForActiveDay();
openSaturday();
}
} else if (item.classList[0] === "forwards-selector") {
if (day1.classList.contains("active")) {
checkForActiveDay();
openMonday();
} else if (day2.classList.contains("active")) {
checkForActiveDay();
openTuesday();
} else if (day3.classList.contains("active")) {
checkForActiveDay();
openWednensday();
} else if (day4.classList.contains("active")) {
checkForActiveDay();
openThursday();
} else if (day5.classList.contains("active")) {
checkForActiveDay();
openFriday();
} else if (day6.classList.contains("active")) {
checkForActiveDay();
openSaturday();
} else {
checkForActiveDay();
openSunday();
}
}
}
function filterTasks(e) {
todoDaysCanvas.forEach((day) => {
const tasks = day.childNodes;
console.log(tasks);
tasks.forEach((task) => {
switch (e.target.value) {
case "all":
task.style.display = "flex";
break;
case "completed":
if (task.classList.contains("completed")) {
task.style.display = "flex";
} else {
task.style.display = "none";
}
break;
case "uncompleted":
if (!task.classList.contains("completed")) {
task.style.display = "flex";
} else {
task.style.display = "none";
}
break;
}
});
});
}
function saveLocalTasks(task) {
if (day1.classList.contains("active")) {
let taskList1;
if (localStorage.getItem("taskList1") === null) {
taskList1 = [];
} else {
taskList1 = JSON.parse(localStorage.getItem("taskList1"));
}
taskList1.push(task);
localStorage.setItem("taskList1", JSON.stringify(taskList1));
} else if (day2.classList.contains("active")) {
let taskList2;
if (localStorage.getItem("taskList2") === null) {
taskList2 = [];
} else {
taskList2 = JSON.parse(localStorage.getItem("taskList2"));
}
taskList2.push(task);
localStorage.setItem("taskList2", JSON.stringify(taskList2));
} else if (day3.classList.contains("active")) {
let taskList3;
if (localStorage.getItem("taskList3") === null) {
taskList3 = [];
} else {
taskList3 = JSON.parse(localStorage.getItem("taskList3"));
}
taskList3.push(task);
localStorage.setItem("taskList3", JSON.stringify(taskList3));
} else if (day4.classList.contains("active")) {
let taskList4;
if (localStorage.getItem("taskList4") === null) {
taskList4 = [];
} else {
taskList4 = JSON.parse(localStorage.getItem("taskList4"));
}
taskList4.push(task);
localStorage.setItem("taskList4", JSON.stringify(taskList4));
} else if (day5.classList.contains("active")) {
let taskList5;
if (localStorage.getItem("taskList5") === null) {
taskList5 = [];
} else {
taskList5 = JSON.parse(localStorage.getItem("taskList5"));
}
taskList5.push(task);
localStorage.setItem("taskList5", JSON.stringify(taskList5));
} else if (day6.classList.contains("active")) {
let taskList6;
if (localStorage.getItem("taskList6") === null) {
taskList6 = [];
} else {
taskList6 = JSON.parse(localStorage.getItem("taskList6"));
}
taskList6.push(task);
localStorage.setItem("taskList6", JSON.stringify(taskList6));
} else if (day7.classList.contains("active")) {
let taskList7;
if (localStorage.getItem("taskList7") === null) {
taskList7 = [];
} else {
taskList7 = JSON.parse(localStorage.getItem("taskList7"));
}
taskList7.push(task);
localStorage.setItem("taskList7", JSON.stringify(taskList7));
}
}
function getLocalTasks() {
//task recovery for day1
let taskList1;
if (localStorage.getItem("taskList1") === null) {
taskList1 = [];
} else {
taskList1 = JSON.parse(localStorage.getItem("taskList1"));
}
taskList1.forEach((task) => {
const divItem = document.createElement("div");
divItem.classList.add("todo-container");
//adding classes to identify different day's tasks
const newItem = document.createElement("li");
newItem.innerText = task;
newItem.classList.add("todo-item");
//Check mark button
const completedBtn = document.createElement("button");
completedBtn.innerHTML = "<i class='fas fa-check'></i>";
completedBtn.classList.add("completed-btn");
//Trash button
const trashBtn = document.createElement("button");
trashBtn.innerHTML = "<i class='fas fa-trash-alt'></i>";
trashBtn.classList.add("trash-btn");
const timerBtn = document.createElement("button");
timerBtn.innerHTML = "<i class='fas fa-clock'></i>";
timerBtn.classList.add("timer-btn");
//this appends the input to the active day in the app
divItem.appendChild(newItem);
divItem.appendChild(completedBtn);
divItem.appendChild(trashBtn);
divItem.appendChild(timerBtn);
day1.appendChild(divItem);
taskNum[0].innerText++;
});
//task recovery for day2
let taskList2;
if (localStorage.getItem("taskList2") === null) {
taskList2 = [];
} else {
taskList2 = JSON.parse(localStorage.getItem("taskList2"));
}
taskList2.forEach((task) => {
const divItem = document.createElement("div");
divItem.classList.add("todo-container");
//adding classes to identify different day's tasks
const newItem = document.createElement("li");
newItem.innerText = task;
newItem.classList.add("todo-item");
//Check mark button
const completedBtn = document.createElement("button");
completedBtn.innerHTML = "<i class='fas fa-check'></i>";
completedBtn.classList.add("completed-btn");
//Trash button
const trashBtn = document.createElement("button");
trashBtn.innerHTML = "<i class='fas fa-trash-alt'></i>";
trashBtn.classList.add("trash-btn");
const timerBtn = document.createElement("button");
timerBtn.innerHTML = "<i class='fas fa-clock'></i>";
timerBtn.classList.add("timer-btn");
//this appends the input to the active day in the app
divItem.appendChild(newItem);
divItem.appendChild(completedBtn);
divItem.appendChild(trashBtn);
divItem.appendChild(timerBtn);
day2.appendChild(divItem);
taskNum[1].innerText++;
});
//task recovery for day3
let taskList3;
if (localStorage.getItem("taskList3") === null) {
taskList3 = [];
} else {
taskList3 = JSON.parse(localStorage.getItem("taskList3"));
}
taskList3.forEach((task) => {
const divItem = document.createElement("div");
divItem.classList.add("todo-container");
//adding classes to identify different day's tasks
const newItem = document.createElement("li");
newItem.innerText = task;
newItem.classList.add("todo-item");
//Check mark button
const completedBtn = document.createElement("button");
completedBtn.innerHTML = "<i class='fas fa-check'></i>";
completedBtn.classList.add("completed-btn");
//Trash button
const trashBtn = document.createElement("button");
trashBtn.innerHTML = "<i class='fas fa-trash-alt'></i>";
trashBtn.classList.add("trash-btn");
const timerBtn = document.createElement("button");
timerBtn.innerHTML = "<i class='fas fa-clock'></i>";
timerBtn.classList.add("timer-btn");
//this appends the input to the active day in the app
divItem.appendChild(newItem);
divItem.appendChild(completedBtn);
divItem.appendChild(trashBtn);
divItem.appendChild(timerBtn);
day3.appendChild(divItem);
taskNum[2].innerText++;
});
//task recovery for day4
let taskList4;
if (localStorage.getItem("taskList4") === null) {
taskList4 = [];
} else {
taskList4 = JSON.parse(localStorage.getItem("taskList4"));
}
taskList4.forEach((task) => {
const divItem = document.createElement("div");
divItem.classList.add("todo-container");
//adding classes to identify different day's tasks
const newItem = document.createElement("li");
newItem.innerText = task;
newItem.classList.add("todo-item");
//Check mark button
const completedBtn = document.createElement("button");
completedBtn.innerHTML = "<i class='fas fa-check'></i>";
completedBtn.classList.add("completed-btn");
//Trash button
const trashBtn = document.createElement("button");
trashBtn.innerHTML = "<i class='fas fa-trash-alt'></i>";
trashBtn.classList.add("trash-btn");
const timerBtn = document.createElement("button");
timerBtn.innerHTML = "<i class='fas fa-clock'></i>";
timerBtn.classList.add("timer-btn");
//this appends the input to the active day in the app
divItem.appendChild(newItem);
divItem.appendChild(completedBtn);
divItem.appendChild(trashBtn);
divItem.appendChild(timerBtn);
day4.appendChild(divItem);
taskNum[3].innerText++;
});
//task recovery for day5
let taskList5;
if (localStorage.getItem("taskList5") === null) {
taskList5 = [];
} else {
taskList5 = JSON.parse(localStorage.getItem("taskList5"));
}
taskList5.forEach((task) => {
const divItem = document.createElement("div");
divItem.classList.add("todo-container");
//adding classes to identify different day's tasks
const newItem = document.createElement("li");
newItem.innerText = task;
newItem.classList.add("todo-item");
//Check mark button
const completedBtn = document.createElement("button");
completedBtn.innerHTML = "<i class='fas fa-check'></i>";
completedBtn.classList.add("completed-btn");
//Trash button
const trashBtn = document.createElement("button");
trashBtn.innerHTML = "<i class='fas fa-trash-alt'></i>";
trashBtn.classList.add("trash-btn");
const timerBtn = document.createElement("button");
timerBtn.innerHTML = "<i class='fas fa-clock'></i>";
timerBtn.classList.add("timer-btn");
//this appends the input to the active day in the app
divItem.appendChild(newItem);
divItem.appendChild(completedBtn);
divItem.appendChild(trashBtn);
divItem.appendChild(timerBtn);
day5.appendChild(divItem);
taskNum[4].innerText++;
});
//task recovery for day6
let taskList6;
if (localStorage.getItem("taskList6") === null) {
taskList6 = [];
} else {
taskList6 = JSON.parse(localStorage.getItem("taskList6"));
}
taskList6.forEach((task) => {
const divItem = document.createElement("div");
divItem.classList.add("todo-container");
//adding classes to identify different day's tasks
const newItem = document.createElement("li");
newItem.innerText = task;
newItem.classList.add("todo-item");
//Check mark button
const completedBtn = document.createElement("button");
completedBtn.innerHTML = "<i class='fas fa-check'></i>";
completedBtn.classList.add("completed-btn");
//Trash button
const trashBtn = document.createElement("button");
trashBtn.innerHTML = "<i class='fas fa-trash-alt'></i>";
trashBtn.classList.add("trash-btn");
const timerBtn = document.createElement("button");
timerBtn.innerHTML = "<i class='fas fa-clock'></i>";
timerBtn.classList.add("timer-btn");
//this appends the input to the active day in the app
divItem.appendChild(newItem);
divItem.appendChild(completedBtn);
divItem.appendChild(trashBtn);
divItem.appendChild(timerBtn);
day6.appendChild(divItem);
taskNum[5].innerText++;
});
//task recovery for day7
let taskList7;
if (localStorage.getItem("taskList7") === null) {
taskList7 = [];
} else {
taskList7 = JSON.parse(localStorage.getItem("taskList7"));
}
taskList7.forEach((task) => {
const divItem = document.createElement("div");
divItem.classList.add("todo-container");
//adding classes to identify different day's tasks
const newItem = document.createElement("li");
newItem.innerText = task;
newItem.classList.add("todo-item");
//Check mark button
const completedBtn = document.createElement("button");
completedBtn.innerHTML = "<i class='fas fa-check'></i>";
completedBtn.classList.add("completed-btn");
//Trash button
const trashBtn = document.createElement("button");
trashBtn.innerHTML = "<i class='fas fa-trash-alt'></i>";
trashBtn.classList.add("trash-btn");
const timerBtn = document.createElement("button");
timerBtn.innerHTML = "<i class='fas fa-clock'></i>";
timerBtn.classList.add("timer-btn");
//this appends the input to the active day in the app
divItem.appendChild(newItem);
divItem.appendChild(completedBtn);
divItem.appendChild(trashBtn);
divItem.appendChild(timerBtn);
day7.appendChild(divItem);
taskNum[6].innerText++;
});
}
//remove local tasks
function removeLocalTasks(task) {
//day1
const taskIndex = task.children[0].innerText;
if (day1.classList.contains("active")) {
let taskList1;
if (localStorage.getItem("taskList1") === null) {
taskList1 = [];
} else {
taskList1 = JSON.parse(localStorage.getItem("taskList1"));
}
taskList1.splice(taskList1.indexOf(taskIndex), 1);
localStorage.setItem("taskList1", JSON.stringify(taskList1));
} else if (day2.classList.contains("active")) {
//day2
let taskList2;
if (localStorage.getItem("taskList2") === null) {
taskList2 = [];
} else {
taskList2 = JSON.parse(localStorage.getItem("taskList2"));
}
taskList2.splice(taskList2.indexOf(taskIndex), 1);
localStorage.setItem("taskList2", JSON.stringify(taskList2));
} else if (day3.classList.contains("active")) {
//day3
let taskList3;
if (localStorage.getItem("taskList3") === null) {
taskList3 = [];
} else {
taskList3 = JSON.parse(localStorage.getItem("taskList3"));
}
taskList3.splice(taskList3.indexOf(taskIndex), 1);
localStorage.setItem("taskList3", JSON.stringify(taskList3));
} else if (day4.classList.contains("active")) {
//day4
let taskList4;
if (localStorage.getItem("taskList4") === null) {
taskList4 = [];
} else {
taskList4 = JSON.parse(localStorage.getItem("taskList4"));
}
taskList4.splice(taskList4.indexOf(taskIndex), 1);
localStorage.setItem("taskList4", JSON.stringify(taskList4));
} else if (day5.classList.contains("active")) {
//day5
let taskList5;
if (localStorage.getItem("taskList5") === null) {
taskList5 = [];
} else {
taskList5 = JSON.parse(localStorage.getItem("taskList5"));
}
taskList5.splice(taskList5.indexOf(taskIndex), 1);
localStorage.setItem("taskList5", JSON.stringify(taskList5));
} else if (day6.classList.contains("active")) {
//day6
let taskList6;
if (localStorage.getItem("taskList6") === null) {
taskList6 = [];
} else {
taskList6 = JSON.parse(localStorage.getItem("taskList6"));
}
taskList6.splice(taskList6.indexOf(taskIndex), 1);
localStorage.setItem("taskList6", JSON.stringify(taskList6));
} else {
//day7
let taskList7;
if (localStorage.getItem("taskList7") === null) {
taskList7 = [];
} else {
taskList7 = JSON.parse(localStorage.getItem("taskList7"));
}
taskList7.splice(taskList7.indexOf(taskIndex), 1);
localStorage.setItem("taskList7", JSON.stringify(taskList7));
}
}