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