forked from Madhumitha/dayPlanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
162 lines (119 loc) · 3.51 KB
/
main.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
// Author: Madhumitha Prabakaran
// Declare variables
let timeNow = moment().format('dddd, MMMM Do YYYY');
let hourNow = moment().format('h');
let hourNow24= parseInt(moment().format('HH'));
let hourNowInt = parseInt(hourNow);
let Timer;
const hour1 = $('#time1').text();
const hour2 = $('#time2').text();
const hour3 = $('#time3').text();
const hour4 = $('#time4').text();
const hour5 = $('#time5').text();
const hour6 = $('#time6').text();
const hour7 = $('#time7').text();
const hour8 = $('#time8').text();
const hour9 = $('#time9').text();
const hour1Int = parseInt(hour1);
const hour2Int = parseInt(hour2);
const hour3Int = parseInt(hour3);
const hour4Int = parseInt(hour4);
const hour5Int = parseInt(hour5);
const hour6Int = parseInt(hour6);
const hour7Int = parseInt(hour7);
const hour8Int = parseInt(hour8);
const hour9Int = parseInt(hour9);
// Store user input in local Storage
$('#btn1').click(function() {
if($('#text1').val()) {
localStorage.removeItem('text1');
}
const hour1String = JSON.stringify(hour1);
localStorage.setItem(hour1, $('#text1').val());
});
$('#btn2').click(function() {
if($('#text2').val()) {
localStorage.removeItem('text2');
}
const hour2String = JSON.stringify(hour2);
localStorage.setItem(hour2, $('#text2').val());
});
$('#btn3').click(function() {
if($('#text3').val()) {
localStorage.removeItem('text3');
}
const hour3String = JSON.stringify(hour3);
localStorage.setItem(hour3, $('#text3').val());
});
$('#btn4').click(function() {
if($('#text4').val()) {
localStorage.removeItem('text4');
}
const hour4String = JSON.stringify(hour4);
localStorage.setItem(hour4, $('#text4').val());
});
$('#btn5').click(function() {
if($('#text5').val()) {
localStorage.removeItem('text5');
}
const hour5String = JSON.stringify(hour5);
localStorage.setItem(hour5, $('#text5').val());
});
$('#btn6').click(function() {
if($('#text6').val()) {
localStorage.removeItem('text6');
}
const hour6String = JSON.stringify(hour6);
localStorage.setItem(hour6, $('#text6').val());
});
$('#btn7').click(function() {
if($('#text7').val()) {
localStorage.removeItem('text7');
}
const hour7String = JSON.stringify(hour7);
localStorage.setItem(hour7, $('#text7').val());
})
$('#btn8').click(function() {
if($('#text8').val()) {
localStorage.removeItem('text8');
}
const hour8String = JSON.stringify(hour8);
localStorage.setItem("text8", $('#text8').val());
})
$('#btn9').click(function() {
if($('#text9').val()) {
localStorage.removeItem('text9');
}
const hour9String = JSON.stringify(hour9);
localStorage.setItem(hour9, $('#text9').val());
})
// Display the time using moment.js
$('#currentDay').append(timeNow);
// Color coding to reflect whether the time slot is in the past, the present or the future
colorCoding();
function colorCoding() {
TIMER = setInterval(colorCoding, 1000);
// Test check: hourNow24 = 20;
if(hourNow24 >= 9 && hourNow24 <= 17) {
for (let i =1; i<=9 ; i++) {
let hourInInt = parseInt($('#time'+i).text());
if (hourInInt < 9) {
hourInInt = hourInInt + 12;
}
if (hourInInt == hourNow24) {
$('#text'+i).css('background-color', '#FB8F78');
continue;
}
if (hourInInt < hourNow24) {
$('#text'+i).css('background-color', 'lightgray');
}
else {
$('#text'+i).css('background-color', 'lightgreen');
}
}
}
else {
clearInterval(TIMER);
$('textarea').css('background-color', 'pink');
}
}