mirror of
https://github.com/manilarome/the-glorious-startpage.git
synced 2024-11-24 00:23:39 +01:00
right dashboard greeter message cleanup
This commit is contained in:
parent
5762af432a
commit
a6fce8a7b9
@ -3,15 +3,7 @@ var dateMessage = document.getElementById("dateMessage");
|
||||
|
||||
var date = new Date();
|
||||
var hour = date.getHours();
|
||||
|
||||
var greeterSuffix = "";
|
||||
if (hour >= 6 && hour < 12) {
|
||||
greeterSuffix = "Morning";
|
||||
} else if (hour >= 12 && hour < 18) {
|
||||
greeterSuffix = "Afternoon";
|
||||
} else {
|
||||
greeterSuffix = "Evening";
|
||||
}
|
||||
var greeterSuffix;
|
||||
|
||||
const monthsArr = [
|
||||
"January",
|
||||
@ -38,10 +30,24 @@ const daysArr = [
|
||||
"Saturday"
|
||||
]
|
||||
|
||||
function getDayOrdinal(day) {
|
||||
return day + (day > 0 ? ['th', 'st', 'nd', 'rd'][(day > 3 && day < 21) || day % 10 > 3 ? 0 : day % 10] : '');
|
||||
const getDayOrdinal = (day) => {
|
||||
return day + (day > 0 ? ['th', 'st', 'nd', 'rd'][(day > 3 && day < 21) ||
|
||||
day % 10 > 3 ? 0 : day % 10] : '');
|
||||
}
|
||||
|
||||
const updateGreeterDateMessage = () => {
|
||||
if (hour >= 6 && hour < 12) {
|
||||
greeterSuffix = "Morning";
|
||||
} else if (hour >= 12 && hour < 18) {
|
||||
greeterSuffix = "Afternoon";
|
||||
} else {
|
||||
greeterSuffix = "Evening";
|
||||
}
|
||||
|
||||
greeterMessage.innerHTML = "Good" + "<br>" + greeterSuffix + "!";
|
||||
|
||||
dateMessage.innerHTML = "Today is the " + getDayOrdinal(date.getDate()) +
|
||||
" of " + monthsArr[date.getMonth()] + ", and it's " + daysArr[date.getDay()] + ".";
|
||||
}
|
||||
|
||||
window.onload = updateGreeterDateMessage();
|
Loading…
Reference in New Issue
Block a user