Bento/assets/js/greeting.js

28 lines
996 B
JavaScript
Raw Normal View History

2021-08-14 11:49:20 -05:00
// ┌─┐┬─┐┌─┐┌─┐┌┬┐┬┌┐┌┌─┐┌─┐
// │ ┬├┬┘├┤ ├┤ │ │││││ ┬└─┐
// └─┘┴└─└─┘└─┘ ┴ ┴┘└┘└─┘└─┘
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-07-05 22:47:21 -05:00
const name = CONFIG.name;
2020-08-14 12:28:56 -05:00
2020-09-27 19:21:23 -05:00
// Here you can change your greetings
2021-07-05 22:47:21 -05:00
const gree1 = `${CONFIG.greetingNight}\xa0`;
const gree2 = `${CONFIG.greetingMorning}\xa0`;
const gree3 = `${CONFIG.greetingAfternoon}\xa0`;
const gree4 = `${CONFIG.greetingEvening}\xa0`;
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
}