Implement giveaway closure logic with new giveaway-gate.js, update .htaccess for redirection after giveaway ends, and modify index.html and styles to reflect giveaway status. Enhance script.js to manage giveaway timer and visibility of related elements.

This commit is contained in:
blake committed 2026-10-23 11:14:02 -05:00
1 parent e376355464
commit 4a7d0a2665
6 files changed
+56 -21

No files matched your search

+7
View File
@@ -5,6 +5,13 @@ DirectorySlash Off
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
RewriteEngine On RewriteEngine On
# Giveaway stays up through the end of November 1, 2026 (Central),
# which is 2026-11-02 06:00:00 UTC. After that, /giveaway sends visitors home.
# This redirect is temporary so the page can be reused: update this timestamp
# together with GIVEAWAY_CLOSE in giveaway-gate.js.
RewriteCond %{TIME} >=20261102060000
RewriteRule ^giveaway(?:/index\.html)?/?$ / [R=302,L]
# Old /html/... addresses # Old /html/... addresses
RewriteRule ^html/services/([^/]+)/?(?:index\.html)?$ /services/$1 [R=301,L] RewriteRule ^html/services/([^/]+)/?(?:index\.html)?$ /services/$1 [R=301,L]
RewriteRule ^html/(about|giveaway)/?(?:index\.html)?$ /$1 [R=301,L] RewriteRule ^html/(about|giveaway)/?(?:index\.html)?$ /$1 [R=301,L]
+7
View File
@@ -151,6 +151,13 @@ address {
text-underline-offset: 0.25rem; text-underline-offset: 0.25rem;
} }
html.giveaway-closed .giveaway-banner:link,
html.giveaway-closed .giveaway-banner:visited,
html.giveaway-closed .giveaway-section,
html.giveaway-closed .giveaway-form-section {
display: none;
}
.giveaway-timer-units { .giveaway-timer-units {
display: flex; display: flex;
gap: 1.2rem; gap: 1.2rem;
+16
View File
@@ -0,0 +1,16 @@
// Runs before the page paints. Closes the giveaway at the end of
// November 1, 2026 (Central), which is 2026-11-02 06:00:00 UTC.
// To run the page again, update this instant and the matching
// timestamp in .htaccess.
(function () {
var closeAt = "2026-11-02T06:00:00Z";
window.GIVEAWAY_CLOSE = closeAt;
if (Date.now() < Date.parse(closeAt)) return;
document.documentElement.classList.add("giveaway-closed");
if (/\/giveaway(?:\/index\.html)?\/?$/.test(location.pathname)) {
location.replace("/");
}
})();
+1
View File
@@ -23,6 +23,7 @@
<link rel="stylesheet" href="../css/style.css" /> <link rel="stylesheet" href="../css/style.css" />
<link rel="stylesheet" href="../css/queries.css" /> <link rel="stylesheet" href="../css/queries.css" />
<script src="../giveaway-gate.js"></script>
<script src="../script.js" defer></script> <script src="../script.js" defer></script>
<link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.googleapis.com" />
+1 -2
View File
@@ -23,6 +23,7 @@
<link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/queries.css" /> <link rel="stylesheet" href="css/queries.css" />
<script src="giveaway-gate.js"></script>
<script src="script.js" defer></script> <script src="script.js" defer></script>
<link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.googleapis.com" />
@@ -44,7 +45,6 @@
<div class="page-transition"></div> <div class="page-transition"></div>
<header class="header"> <header class="header">
<nav class="nav"> <nav class="nav">
<!--
<a class="giveaway-banner" href="/giveaway"> <a class="giveaway-banner" href="/giveaway">
<span class="giveaway-banner-label">Enter our giveaway</span> <span class="giveaway-banner-label">Enter our giveaway</span>
<span class="giveaway-banner-dot" aria-hidden="true">·</span> <span class="giveaway-banner-dot" aria-hidden="true">·</span>
@@ -58,7 +58,6 @@
<span class="giveaway-timer-closed" hidden>Closed</span> <span class="giveaway-timer-closed" hidden>Closed</span>
</span> </span>
</a> </a>
-->
<div class="nav-icons"> <div class="nav-icons">
<a href="https://www.instagram.com/sioux_diamond_detailing/" <a href="https://www.instagram.com/sioux_diamond_detailing/"
><img ><img
+24 -19
View File
@@ -178,35 +178,37 @@ galleries.forEach((gallery) => {
}); });
}); });
// Giveaway closes at the end of November 1, 2026 (Central Time). // Same instant as giveaway-gate.js and the .htaccess redirect:
const GIVEAWAY_CLOSE = new Date("2026-11-02T06:00:00Z"); // the end of November 1, 2026 (Central Time).
const GIVEAWAY_CLOSE = new Date(
window.GIVEAWAY_CLOSE || "2026-11-02T06:00:00Z",
);
function isGiveawayPage() {
return /\/giveaway(?:\/index\.html)?\/?$/.test(location.pathname);
}
function updateGiveawayTimers() { function updateGiveawayTimers() {
const timers = document.querySelectorAll("[data-giveaway-timer]"); const timers = document.querySelectorAll("[data-giveaway-timer]");
const remaining = GIVEAWAY_CLOSE.getTime() - Date.now();
const closed = remaining <= 0;
if (closed) {
clearInterval(giveawayTimerId);
document.documentElement.classList.add("giveaway-closed");
if (isGiveawayPage()) location.replace("/");
return;
}
if (!timers.length) return; if (!timers.length) return;
const remaining = GIVEAWAY_CLOSE.getTime() - Date.now(); const totalSeconds = Math.floor(remaining / 1000);
const totalSeconds = Math.max(0, Math.floor(remaining / 1000));
const days = Math.floor(totalSeconds / 86400); const days = Math.floor(totalSeconds / 86400);
const hours = Math.floor((totalSeconds % 86400) / 3600); const hours = Math.floor((totalSeconds % 86400) / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60); const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = totalSeconds % 60; const seconds = totalSeconds % 60;
const closed = remaining <= 0;
timers.forEach((timer) => { timers.forEach((timer) => {
const units = timer.querySelector(
".giveaway-timer-units, .giveaway-countdown-units",
);
const closedMessage = timer.querySelector(".giveaway-timer-closed");
if (closed) {
timer.classList.add("is-closed");
if (units) units.hidden = true;
if (closedMessage) closedMessage.hidden = false;
timer.setAttribute("aria-label", "Giveaway closed");
return;
}
const daysEl = timer.querySelector("[data-days]"); const daysEl = timer.querySelector("[data-days]");
const hoursEl = timer.querySelector("[data-hours]"); const hoursEl = timer.querySelector("[data-hours]");
const minutesEl = timer.querySelector("[data-minutes]"); const minutesEl = timer.querySelector("[data-minutes]");
@@ -222,5 +224,8 @@ function updateGiveawayTimers() {
}); });
} }
let giveawayTimerId;
if (document.querySelector("[data-giveaway-timer]") || isGiveawayPage()) {
giveawayTimerId = setInterval(updateGiveawayTimers, 1000);
updateGiveawayTimers(); updateGiveawayTimers();
setInterval(updateGiveawayTimers, 1000); }