-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
108 lines (97 loc) · 3.1 KB
/
script.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
var m = moment();
var currentDate =
moment().format('dddd') + ', ' + moment().format('MMMM Do, YYYY');
var currentHour = moment().format('h:mm:ss a');
var interval = setInterval(function () {
var momentNow = moment();
$('#currentDay').html(
momentNow.format('YYYY MMMM DD') +
' ' +
momentNow.format('dddd').substring(0, 3).toUpperCase()
);
$('#currentDay').html(currentDate + ' ' + momentNow.format('hh:mm:ss A'));
}, 100);
$(document).ready(function () {
colorChange();
renderText();
});
function colorChange() {
var currentTime = moment().hours();
$('.input').each(function () {
var scheduledTime = parseInt($(this).attr('id'));
if (currentTime > scheduledTime) {
$(this).removeClass('future');
$(this).removeClass('present');
$(this).addClass('past');
} else if (currentTime < scheduledTime) {
$(this).removeClass('present');
$(this).removeClass('past');
$(this).addClass('future');
} else {
$(this).removeClass('future');
$(this).removeClass('past');
$(this).addClass('present');
}
});
}
var eventText;
var eventTime;
$('.saveBtn').click(function () {
eventText = $(this).siblings('.input').val();
eventTime = $(this).siblings('.hour').text();
localStorage.setItem(eventTime, JSON.stringify(eventText));
colorChange();
renderText();
});
$('.deleteBtn').click(function () {
eventText = $(this).siblings('.input').val('');
eventText = $(this).siblings('.input').val();
eventTime = $(this).siblings('.hour').text();
localStorage.setItem(eventTime, JSON.stringify(eventText));
colorChange();
renderText();
});
$('.clearDayBtn').on('click', function () {
localStorage.clear();
renderText();
});
function renderText() {
var saveEventText1 = JSON.parse(localStorage.getItem('09:00 AM'));
$('#9').val('');
$('#9').val(saveEventText1);
var saveEventText2 = JSON.parse(localStorage.getItem('10:00 AM'));
$('#10').val('');
$('#10').val(saveEventText2);
var saveEventText3 = JSON.parse(localStorage.getItem('11:00 AM'));
$('#11').val('');
$('#11').val(saveEventText3);
var saveEventText4 = JSON.parse(localStorage.getItem('12:00 PM'));
$('#12').val('');
$('#12').val(saveEventText4);
var saveEventText5 = JSON.parse(localStorage.getItem('01:00 PM'));
$('#13').val('');
$('#13').val(saveEventText5);
var saveEventText6 = JSON.parse(localStorage.getItem('02:00 PM'));
$('#14').val('');
$('#14').val(saveEventText6);
var saveEventText7 = JSON.parse(localStorage.getItem('03:00 PM'));
$('#15').val('');
$('#15').val(saveEventText7);
var saveEventText8 = JSON.parse(localStorage.getItem('04:00 PM'));
$('#16').val('');
$('#16').val(saveEventText8);
var saveEventText9 = JSON.parse(localStorage.getItem('05:00 PM'));
$('#17').val('');
$('#17').val(saveEventText9);
}
function autoReload() {
var current = new Date();
var future = new Date();
future.setTime(future.getTime() + 3600000); //3600000 = 1 hour
future.setMinutes(0);
future.setSeconds(0);
var timeout = future.getTime() - current.getTime();
setTimeout(function () {
window.location.reload(true);
}, timeout);
}