-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
70 lines (59 loc) · 2.27 KB
/
script.js
File metadata and controls
70 lines (59 loc) · 2.27 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
var appointText = "";
var appointTime = "";
var currentDate;
var currentTime;
var currentContainer;
var tempArray = [];
var storedAppointments;
var returnedAppointments;
$(window).on("load", function () {
currentDate = moment().format("dddd MMM Do YYYY, h:mm a");
$("#currentDay").append(currentDate);
currentTime = moment().format("H");
function renderAppointments() {
storedAppointments = JSON.parse(localStorage.getItem("appointments"));
if (storedAppointments !== null) {
for (i = 0; i < storedAppointments.length; i++) {
returnedAppointments = storedAppointments[i];
details = returnedAppointments.details;
timeIndex = returnedAppointments.time;
timeIndex = timeIndex.replace(":00", '');
if (details !== null) {
$("#" + timeIndex).children('div').children('div').children('textarea').val(details);
}
}
}
}
renderAppointments();
for (i = 0; i <= 23; i++) {
CurrentContainer = i;
if (currentTime == i) {
$('#' + CurrentContainer).addClass("present");
$('#' + CurrentContainer).children('div').children('div').children("textarea").addClass("present");
}
else if (currentTime > i) {
$('#' + CurrentContainer).addClass("past");
$('#' + CurrentContainer).children('div').children('div').children("textarea").addClass("past");
}
else {
$('#' + CurrentContainer).addClass("future");
$('#' + CurrentContainer).children('div').children('div').children("textarea").addClass("future");
}
}
})
$(".saveBtn").click(function () {
appointText = $(this).parent('div').children('div').children('textarea').val();
appointTime = $(this).parent('div').parent().attr("id");
appointment = {
time: appointTime,
details: appointText
}
tempArray = JSON.parse(localStorage.getItem("appointments"));
if (tempArray === null) {
localStorage.setItem('appointments', JSON.stringify([{ time: appointTime, details: appointText }]));
}
else {
tempArray.push(appointment);
localStorage.setItem("appointments", JSON.stringify(tempArray));
}
})