diff --git a/css/greeter-date-message.css b/css/greeter-date-message.css new file mode 100644 index 0000000..5c216f3 --- /dev/null +++ b/css/greeter-date-message.css @@ -0,0 +1,13 @@ +#greeterMessage { + color: var(--base-color); + font-size: 32pt; + font-family: roboto-light; + margin: 5px; +} + +#dateMessage { + color: #f2f2f2; + font-size: 12pt; + font-family: roboto; + margin: 5px; +} \ No newline at end of file diff --git a/css/style.css b/css/style.css index 7c7ec49..0b2813b 100644 --- a/css/style.css +++ b/css/style.css @@ -10,6 +10,7 @@ @import url('profile-image.css'); @import url('search-box.css'); @import url('dashboard.css'); +@import url('greeter-date-message.css'); :root { /* Colors */ diff --git a/index.html b/index.html index 38c34bc..1127cef 100644 --- a/index.html +++ b/index.html @@ -57,7 +57,9 @@
-

gagoka

+
+
+
@@ -70,5 +72,6 @@ + \ No newline at end of file diff --git a/js/greeter-date-message.js b/js/greeter-date-message.js new file mode 100644 index 0000000..6ef9508 --- /dev/null +++ b/js/greeter-date-message.js @@ -0,0 +1,47 @@ +var greeterMessage = document.getElementById("greeterMessage"); +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"; +} + +const monthsArr = [ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December" +]; + +const daysArr = [ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday" +] + +function getDayOrdinal(day) { + return day + (day > 0 ? ['th', 'st', 'nd', 'rd'][(day > 3 && day < 21) || day % 10 > 3 ? 0 : day % 10] : ''); +} + +greeterMessage.innerHTML = "Good" + "
" + greeterSuffix + "!"; +dateMessage.innerHTML = "Today is the " + getDayOrdinal(date.getDate()) + + " of " + monthsArr[date.getMonth()] + ", and it's " + daysArr[date.getDay()] + "."; \ No newline at end of file