-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
27 lines (25 loc) · 879 Bytes
/
index.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
'use strict';
/**
* Changes the message about the current food day
* Reruns at midnight
*/
function updateFoodMessage() {
let menu = [
'Sundae Sunday', 'Meatloaf Monday', 'Thai Tuesday', 'Waffle Wednesday',
'Turnip Thursday', 'Fried Food Friday', 'Salmon Saturday'
];
let location =
['freezer', 'fridge', 'fridge', 'fridge', 'pantry', 'fridge', 'grill'];
let today = new Date();
let i = today.getDay();
document.getElementById('food-message').innerHTML = menu[i];
document.getElementById('food-location').innerHTML = location[i];
let tomorrow =
new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1);
let timeToMidnight = tomorrow - today;
setTimeout(updateFoodMessage, timeToMidnight);
}
if (document.readyState == 'Loading')
window.addEventListener('DOMContentLoaded', updateFoodMessage);
else
updateFoodMessage();