-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
41 lines (33 loc) · 1.18 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
// Establish current date and display in header
var curentDay = moment().format("dddd, MMMM Do");
$("#currentDay").text(curentDay);
// Convert time from 24hr to 12hr
function convert(currentHour) {
return moment(currentHour, "HH:mm:ss").format("h:mm:ss A");
}
// Check to see if present time has preceeded or passed the scheduled event
function currentTime() {
var currentHour = moment().hours();
console.log(convert(currentHour));
$(".time-block").each(function(){
var hourStr = $(this).attr("id");
var hour = parseInt(hourStr.split("-")[1]);
if(hour < (convert(currentHour))){
$(this).addClass("past");
} else if(hour === (convert(currentHour))){
$(this).removeClass("past");
$(this).addClass("present");
} else {
$(this).removeClass("past");
$(this).removeClass("present");
$(this).addClass("future");
}
})
}
// call function
currentTime();
// store events on local storage
$(".saveBtn").click(function(){
localStorage.setItem("description", "description");
document.getElementById("description").innerHTML = localStorage.getItem("description");
});