Bento/js/greeting.js

26 lines
784 B
JavaScript
Raw Normal View History

2020-09-27 19:21:23 -05:00
// Get the hour
2021-01-03 20:54:21 -06:00
const today = new Date();
const hour = today.getHours();
2020-08-14 12:33:18 -05:00
2020-09-27 19:21:23 -05:00
// Here you can change your name
2021-01-09 23:56:22 -06:00
const name = ' John Doe';
2020-08-14 12:28:56 -05:00
2020-09-27 19:21:23 -05:00
// Here you can change your greetings
2021-01-09 23:56:22 -06:00
const gree1 = 'Go to Sleep! ';
const gree2 = 'Good morning! ';
const gree3 = 'Good afternoon ';
const gree4 = 'Good evening, ';
const gree5 = 'Good evening, ';
const gree6 = 'Good evening, ';
2020-09-27 19:21:23 -05:00
// Define the hours of the greetings
2020-11-02 20:23:16 -06:00
if (hour >= 23 && hour < 5) {
2021-01-03 20:54:21 -06:00
document.getElementById('greetings').innerText = gree1 + name;
2020-11-02 20:23:16 -06:00
} else if (hour >= 6 && hour < 12) {
2021-01-03 20:54:21 -06:00
document.getElementById('greetings').innerText = gree2 + name;
2020-11-02 20:23:16 -06:00
} else if (hour >= 12 && hour < 17) {
2021-01-03 20:54:21 -06:00
document.getElementById('greetings').innerText = gree3 + name;
} else {
document.getElementById('greetings').innerText = gree4 + name;
2020-08-14 12:28:56 -05:00
}