Skip to content

Commit 8723ea1

Browse files
committed
added email waitlist + cachefirstnetwork reval .js strategy
1 parent c252941 commit 8723ea1

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

static/assets/scripts/helpers.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,11 +639,51 @@ async function enforceDonationLockout() {
639639
<h1 style="font-size:2.5em;margin-bottom:0.5em;">CCPorted Is Down</h1>
640640
<p style="font-size:1.2em;">CCPorted has been shut down. Check back next school year!!<br>
641641
In the meantime, <a href ="https://discord.gg/GDEFRBTT3Z">join our discord</a> to hang out.</p>
642+
<p>CCPorted is coming back soon!</p>
643+
<p>Please add your email to the waitlist to be the first to know when we are back online!</p>
644+
<p><input type="email" placeholder="Enter your email" id="waitlist-email" style="padding:10px;width:300px;margin-top:10px;"></p>
645+
<button id="waitlist-submit" style="padding:10px 20px;margin-top:10px;">Join Waitlist</button>
646+
<p id="waitlist-message" style="margin-top:10px;"></p>
647+
642648
</div>
643649
</div>
644650
`;
645651
// Disable all interaction
646652
// document.body.style.pointerEvents = "none";
653+
async function handler() {
654+
const emailInput = document.getElementById("waitlist-email");
655+
const email = emailInput.value.trim();
656+
if (!email) {
657+
document.getElementById("waitlist-message").textContent = "Please enter a valid email address.";
658+
return;
659+
}
660+
661+
document.getElementById("waitlist-message").textContent = "Thank you for joining the waitlist!";
662+
const url = "https://dahljrdecyiwfjgklnvz.supabase.co/rest/v1/email_waitlist";
663+
const response = await fetch(url, {
664+
method: "POST",
665+
headers: {
666+
"Content-Type": "application/json",
667+
"apikey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImRhaGxqcmRlY3lpd2ZqZ2tsbnZ6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjgyNjE3NzMsImV4cCI6MjA0MzgzNzc3M30.8-YlXqSXsYoPTaDlHMpTdqLxfvm89-8zk2HG2MCABRI",
668+
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImRhaGxqcmRlY3lpd2ZqZ2tsbnZ6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjgyNjE3NzMsImV4cCI6MjA0MzgzNzc3M30.8-YlXqSXsYoPTaDlHMpTdqLxfvm89-8zk2HG2MCABRI"
669+
},
670+
body: JSON.stringify({ email: email })
671+
});
672+
if (!response.ok) {
673+
document.getElementById("waitlist-message").textContent = "Failed to join waitlist. Please try again later.";
674+
return;
675+
}
676+
document.getElementById("waitlist-email").disabled = true;
677+
document.getElementById("waitlist-submit").disabled = true;
678+
document.getElementById("waitlist-message").textContent = "Thank you for joining the waitlist! We'll notify you when we're back online.";
679+
}
680+
document.getElementById("waitlist-submit").addEventListener("click", handler);
681+
document.getElementById("waitlist-email").addEventListener("keypress", (e) => {
682+
if (e.key === "Enter") {
683+
e.preventDefault();
684+
handler();
685+
}
686+
});
647687
document.body.style.userSelect = "none";
648688
window.locked = true;
649689
return;

static/sw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ self.addEventListener('fetch', event => {
304304
event.respondWith(cacheFirstStrategy(request));
305305
}
306306
// For HTML and JSON files, use network-first to get latest versions
307-
else if (request.url.endsWith('.html') || request.url.endsWith('.json') || request.url.endsWith('.txt')) {
307+
else if (request.url.endsWith('.html') || request.url.endsWith('.json') || request.url.endsWith('.txt') || request.url.endsWith('.js')) {
308308
event.respondWith(networkFirstStrategy(request));
309309
}
310310
// For everything else cacheable, use time-aware cache

0 commit comments

Comments
 (0)