Attempt to make apply page faster
This commit is contained in:
+14
-12
@@ -137,6 +137,8 @@ import '../styles/apply.scss';
|
|||||||
// === PASTE YOUR GOOGLE SCRIPT URL HERE ONCE ===
|
// === PASTE YOUR GOOGLE SCRIPT URL HERE ONCE ===
|
||||||
const SCRIPT_URL = 'https://script.google.com/macros/s/AKfycby_xG6EGVuLXvgs9ro20rMkK2zSyElPCHeMU_2F2Q_0WE08gtCNzrO-SEyjDAqS46Hr/exec';
|
const SCRIPT_URL = 'https://script.google.com/macros/s/AKfycby_xG6EGVuLXvgs9ro20rMkK2zSyElPCHeMU_2F2Q_0WE08gtCNzrO-SEyjDAqS46Hr/exec';
|
||||||
|
|
||||||
|
const STATUS_CSV_URL = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vRZvHQma9ZHzgyb3tmkCzXKZVpW9esnVAOQEN994ZuUvszO6dhE4fzq0psXLA2lTtDuefUIXNQvvfN_/pub?gid=202325095&single=true&output=csv';
|
||||||
|
|
||||||
// --- ELEMENTS ---
|
// --- ELEMENTS ---
|
||||||
const loadingStatus = document.getElementById('loading-status');
|
const loadingStatus = document.getElementById('loading-status');
|
||||||
const closedMessage = document.getElementById('closed-message');
|
const closedMessage = document.getElementById('closed-message');
|
||||||
@@ -150,24 +152,24 @@ import '../styles/apply.scss';
|
|||||||
const loadingMsg = document.getElementById('loading-msg');
|
const loadingMsg = document.getElementById('loading-msg');
|
||||||
const successMsg = document.getElementById('success-message');
|
const successMsg = document.getElementById('success-message');
|
||||||
|
|
||||||
// --- STEP 1: CHECK GOOGLE SHEET STATUS ---
|
// --- STEP 1: CHECK GOOGLE SHEET STATUS VIA CSV ---
|
||||||
// Added the protective if-statement here!
|
|
||||||
if (loadingStatus && closedMessage && registrationContent) {
|
if (loadingStatus && closedMessage && registrationContent) {
|
||||||
fetch(SCRIPT_URL)
|
// We fetch the lightning-fast CSV instead of the script
|
||||||
.then(response => response.json())
|
fetch(STATUS_CSV_URL)
|
||||||
.then(data => {
|
.then(response => response.text()) // Parse it as raw text, not JSON
|
||||||
loadingStatus.style.display = 'none'; // Hide the spinner
|
.then(csvText => {
|
||||||
|
loadingStatus.style.display = 'none';
|
||||||
|
|
||||||
// Look at the B1 cell value from the Google Sheet
|
// CSV text usually comes with a newline at the end, so we use .trim() to clean it
|
||||||
if (data.status === 'OPEN') {
|
// We also check if it includes 'OPEN' just in case there are other headers
|
||||||
registrationContent.style.display = 'block'; // Reveal the portal!
|
if (csvText.trim().includes('OPEN')) {
|
||||||
|
registrationContent.style.display = 'block';
|
||||||
} else {
|
} else {
|
||||||
closedMessage.style.display = 'block'; // Show the closed message
|
closedMessage.style.display = 'block';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error("Status check failed:", error); // Added this to clear the warning
|
console.error("Status check failed:", error);
|
||||||
// If the internet is down or script fails, fail gracefully by showing closed
|
|
||||||
loadingStatus.style.display = 'none';
|
loadingStatus.style.display = 'none';
|
||||||
closedMessage.style.display = 'block';
|
closedMessage.style.display = 'block';
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user