diff --git a/index.html b/index.html index 1358655..0604eb1 100644 --- a/index.html +++ b/index.html @@ -112,9 +112,9 @@

Shop Hours

-

Tuesday - Friday: 10:00 - 5:00

-

Saturday: 9:00 - 3:00

-

Sunday - Monday: Closed

+

Tuesday - Friday: 10:00 - 5:00

+

Saturday: 9:00 - 3:00

+

Sunday - Monday: Closed

diff --git a/script.js b/script.js index 3668a1e..c965087 100644 --- a/script.js +++ b/script.js @@ -1,3 +1,4 @@ +let statusInterval; // Mobile NavBar document.addEventListener('DOMContentLoaded', () => { @@ -68,12 +69,20 @@ document.addEventListener("DOMContentLoaded", function () { lightbox.className = "lightbox"; lightbox.innerHTML = ` × + + `; document.body.appendChild(lightbox); } + // Ensure the close button listener is always attached when lightbox is opened + document.querySelector(".lightbox .close").addEventListener("click", function(event) { + event.preventDefault(); + document.getElementById("lightbox").style.display = "none"; + }); + let lightboxImg = document.getElementById("lightbox-img"); let lightboxCaption = document.getElementById("lightbox-caption"); let caption = images[currentIndex].parentElement.querySelector(".caption").textContent; @@ -82,8 +91,8 @@ document.addEventListener("DOMContentLoaded", function () { lightboxCaption.textContent = caption; lightbox.style.display = "flex"; - // document.getElementById("prev").onclick = () => navigateLightbox(-1); - // document.getElementById("next").onclick = () => navigateLightbox(1); + document.querySelector(".lightbox .prev").onclick = () => navigateLightbox(-1); + document.querySelector(".lightbox .next").onclick = () => navigateLightbox(1); } function navigateLightbox(direction) { @@ -168,63 +177,13 @@ function scrollFunction() { } } -// 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 updateBusinessHours() { - const now = new Date(); - if (document.body.scrollTop > 130 || document.documentElement.scrollTop > 130) { - mybutton.style.display = "block"; - } else { - mybutton.style.display = "none"; - } -} - // 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); +// The open/closed sign function is now in update.js function injectPlausibleScript() { const plausibleDomain = "beachpartyballoons.com"; @@ -250,5 +209,5 @@ function injectPlausibleScript() { console.log('Plausible script and function have been injected into the head.'); } - // Run the function when the window loads. - window.onload = injectPlausibleScript; + // Run the function when the DOM is ready. + document.addEventListener('DOMContentLoaded', injectPlausibleScript); diff --git a/update.js b/update.js index 7ff6a0f..64dba31 100644 --- a/update.js +++ b/update.js @@ -1,24 +1,72 @@ document.addEventListener('DOMContentLoaded', () => { const message = document.getElementById('message'); - + const statusElement = document.getElementById('status'); + const hoursTuesdayFriday = document.getElementById('hours-tuesday-friday'); + const hoursSaturday = document.getElementById('hours-saturday'); + const hoursSundayMonday = document.getElementById('hours-sunday-monday'); + + let statusInterval; + + function checkStatus() { + const now = new Date(); + const checkHour = now.getHours(); + let isOpen = false; + + const daysOfWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; + const currentDay = daysOfWeek[now.getDay()]; + + const operatingHours = { + "Sunday": { start: 0, end: 0 }, + "Monday": { start: 0, end: 0 }, + "Tuesday": { start: 10, end: 17 }, + "Wednesday": { start: 10, end: 17 }, + "Thursday": { start: 10, end: 17 }, + "Friday": { start: 10, end: 17 }, + "Saturday": { start: 9, end: 15 } + }; + + if (operatingHours[currentDay]) { + const { start, end } = operatingHours[currentDay]; + isOpen = checkHour >= start && checkHour < end; + } + + if (statusElement) { + statusElement.textContent = isOpen ? "We are currently OPEN" : "We are currently CLOSED"; + } + } fetch('update.json') .then(response => response.json()) .then(data => { - - const update = data[0]; + const update = data[0]; - message.textContent = update.message; - - const updateElement = document.querySelector('.update'); // safer than getElementsByClassName -if (update.message === "") { - updateElement.style.display = "none"; -} + // Handle the top message + if (update.message && update.message.trim() !== "") { + message.textContent = update.message; + } else { + const updateElement = document.querySelector('.update'); + if (updateElement) { + updateElement.style.display = "none"; + } + } + // Handle the closed override and regular status + if (update.isClosed) { + if (statusInterval) { + clearInterval(statusInterval); + } + if (statusElement) { + statusElement.textContent = update.closedMessage; + } + } else { + checkStatus(); // Initial check + statusInterval = setInterval(checkStatus, 60000); // Update every minute + } }) .catch(error => { console.error('Error fetching data:', error); - businessCard.innerHTML = '

Error loading data. Check the console.

'; // Display an error message + if (statusElement) { + statusElement.textContent = 'Error loading status.'; + } }); }); - diff --git a/update.json b/update.json index bc1fdd6..15e3522 100644 --- a/update.json +++ b/update.json @@ -1,5 +1,7 @@ [ { - "message": "" + "message": "", + "isClosed": false, + "closedMessage": "We are temporarily closed. Please check back later for updates." } -] \ No newline at end of file +]