update HTML on hours widget

This commit is contained in:
Mark Eaton
2022-08-25 15:23:47 -04:00
parent 7b3b50b017
commit ea10e54d65
+17 -5
View File
@@ -1,5 +1,7 @@
<div id="hours-content"></div> <div id="hours-content-container">
<p>More detailed information is available on our <a href="https://library.kbcc.cuny.edu/calendar">hours</a> page.</p> <div id="hours-content"></div>
<p>See our <a href="https://library.kbcc.cuny.edu/calendar">hours</a> page for more info.</p>
</div>
<script> <script>
@@ -22,7 +24,7 @@ $.ajax({
const isToday = (today.toDateString() == date.toDateString()); const isToday = (today.toDateString() == date.toDateString());
if (isToday) { if (isToday) {
if (start_and_end.length === 1) { if (start_and_end.length === 1) {
document.getElementById("hours-content").innerHTML += "The library is CLOSED today.<br />" document.getElementById("hours-content").innerHTML += "The library is <strong>CLOSED</strong> today.<br />"
} else { } else {
let start = start_and_end[0]; let start = start_and_end[0];
let end = start_and_end[1]; let end = start_and_end[1];
@@ -37,9 +39,9 @@ $.ajax({
console.log("system: " + today.getHours(), "start_24: " + start_24, "end_24: " + end_24); console.log("system: " + today.getHours(), "start_24: " + start_24, "end_24: " + end_24);
let parsed_date = date.toLocaleDateString("en-US", { weekday: 'long', month: 'long', day: 'numeric' }); let parsed_date = date.toLocaleDateString("en-US", { weekday: 'long', month: 'long', day: 'numeric' });
if (start_24 <= today.getHours() && today.getHours() < end_24) { if (start_24 <= today.getHours() && today.getHours() < end_24) {
document.getElementById("hours-content").innerHTML += "The library is currently OPEN. Today's hours are " + hours + ".<br />" document.getElementById("hours-content").innerHTML += "The library is currently <strong>OPEN</strong>.<br />Today's hours are <strong>" + hours + "</strong>.<br />"
} else { } else {
document.getElementById("hours-content").innerHTML += "The library is currently CLOSED. Today's hours are " + hours + ".<br />" document.getElementById("hours-content").innerHTML += "The library is currently <strong>CLOSED</strong>.<br />Today's hours are <strong>" + hours + "</strong>.<br />"
} }
} }
} }
@@ -50,3 +52,13 @@ $.ajax({
}); });
</script> </script>
<style>
#hours-content-container {
margin-top: -10px;
text-align: center;
font-size: 1.7em;
}
</style>