From fa6a499de8ded909ac1b6b141be169247d711e6b Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 3 Mar 2025 09:16:46 -0500 Subject: [PATCH] update open status js --- .vscode/settings.json | 2 +- script.js | 64 +++++++++++++++++++++++++++++-------------- style.css | 2 +- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index fc6fbb2..83ac8cf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "liveServer.settings.port": 5511 + "liveServer.settings.port": 5514 } \ No newline at end of file diff --git a/script.js b/script.js index b6491f1..de4f383 100644 --- a/script.js +++ b/script.js @@ -179,27 +179,49 @@ function topFunction() { function updateBusinessHours() { const now = new Date(); - const nowUtc = new Date(now.getTime() + now.getTimezoneOffset() * 60000); // Convert to UTC - const newYorkTime = new Date(nowUtc.getTime() + 5 * 60 * 60 * 1000); // Convert to New York time - - 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 { - // document.getElementById('neon').classList.remove('neonTextOpen'); - // 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.'; + if (document.body.scrollTop > 130 || document.documentElement.scrollTop > 130) { + mybutton.style.display = "block"; + } else { + mybutton.style.display = "none"; } } -updateBusinessHours(); \ No newline at end of file +// 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); diff --git a/style.css b/style.css index 58c63ec..998bfdd 100644 --- a/style.css +++ b/style.css @@ -205,7 +205,7 @@ form{ 0 0 55px #bc13fe, 0 0 70px #bc13fe, 0 0 80px #bc13fe; -}; +} @keyframes pulsateClosed {