-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (35 loc) · 1.05 KB
/
script.js
File metadata and controls
40 lines (35 loc) · 1.05 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
$(function () {
var tDate = $("#currentDay");
var date = dayjs().format("dddd, MMMM D, YYYY h:mm A");
// replaces tdate with text date & time
tDate.text(date);
var currentHour = dayjs().format("H");
//
for (let i = 9; i < 18; i++) {
var timeBlock = $("#hour-" + i);
if (i < currentHour) {
timeBlock.addClass("past");
} else if (i == currentHour) {
timeBlock.addClass("present");
} else {
timeBlock.addClass("future");
}
}
//variable for the button element
var SaveItem = $(".saveBtn");
var thingsToDo = JSON.parse(localStorage.getItem("events")) || {};
SaveItem.on("click", storeEvents);
for (const key in thingsToDo) {
var timeBlockB = $("#" + key).children()[1];
timeBlockB.value = thingsToDo[key];
console.log(timeBlockB);
}
function storeEvents(event) {
var eventStore = {
event: $(this).siblings()[1].value,
time: $(this).parent().attr("id"),
};
thingsToDo[eventStore.time] = eventStore.event;
localStorage.setItem("events", JSON.stringify(thingsToDo));
}
});