update open status js

This commit is contained in:
chris 2025-03-03 09:16:46 -05:00
parent 3e895307d9
commit fa6a499de8
3 changed files with 45 additions and 23 deletions

View File

@ -1,3 +1,3 @@
{ {
"liveServer.settings.port": 5511 "liveServer.settings.port": 5514
} }

View File

@ -179,27 +179,49 @@ function topFunction() {
function updateBusinessHours() { function updateBusinessHours() {
const now = new Date(); const now = new Date();
const nowUtc = new Date(now.getTime() + now.getTimezoneOffset() * 60000); // Convert to UTC if (document.body.scrollTop > 130 || document.documentElement.scrollTop > 130) {
const newYorkTime = new Date(nowUtc.getTime() + 5 * 60 * 60 * 1000); // Convert to New York time mybutton.style.display = "block";
const today = newYorkTime.getDay(); // Get day of the week (0 = Sunday, ..., 6 = Saturday)
const currentHour = newYorkTime.getHours(); // Get hour in 24-hour format
if (today >= 1 && today <= 5) { // Monday to Friday
if (currentHour >= 10 && currentHour < 17) {
// document.getElementById('neon').classList.remove('neonTextClosed');
// document.getElementById('neon').classList.add('neonTextOpen');
document.getElementById('status').textContent = 'We are currently OPEN.';
} else { } else {
// document.getElementById('neon').classList.remove('neonTextOpen'); mybutton.style.display = "none";
// document.getElementById('neon').classList.add('neonTextClosed');
document.getElementById('status').textContent = 'We are currently CLOSED.';
}
} else { // Saturday or Sunday
// document.getElementById('neon').classList.remove('neonTextOpen');
// document.getElementById('neon').classList.add('neonTextClosed');
document.getElementById('status').textContent = 'We are currently CLOSED.';
} }
} }
updateBusinessHours(); // When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE, and Opera
}
// Open/closed sign function
function checkStatus() {
const now = new Date();
const checkHour = now.getHours();
let isOpen = false;
// Define days of operation
const daysOfWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
const currentDay = daysOfWeek[now.getDay()];
const operatingHours = {
"Saturday": { start: 9, end: 15 },
"Tuesday": { start: 10, end: 17 },
"Wednesday": { start: 10, end: 17 },
"Thursday": { start: 10, end: 17 }
};
if (currentDay === "Sunday") {
isOpen = false; // Store is closed on Sundays
} else if (operatingHours[currentDay]) {
const { start, end } = operatingHours[currentDay];
isOpen = checkHour >= start && checkHour < end;
}
// Update the status in the HTML
const statusElement = document.getElementById("status");
if (statusElement) {
statusElement.textContent = isOpen ? "We are currently OPEN" : "We are currently CLOSED";
}
}
// Update status every second
setInterval(checkStatus, 1000);

View File

@ -205,7 +205,7 @@ form{
0 0 55px #bc13fe, 0 0 55px #bc13fe,
0 0 70px #bc13fe, 0 0 70px #bc13fe,
0 0 80px #bc13fe; 0 0 80px #bc13fe;
}; }
@keyframes pulsateClosed { @keyframes pulsateClosed {