Skip to content

Commit

Permalink
Fix r-number handling and add ability to hide banner
Browse files Browse the repository at this point in the history
  • Loading branch information
gbougakov committed Jun 15, 2024
1 parent 6e7be8b commit c460a9f
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 119 deletions.
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ <h2>We're working on an app 📱</h2>
<p>Receive notifications about seat availability. Reserve multiple seats within a day. Use Face ID for booking,
not KU Leuven Authenticator. Sign up to become an early adopter.</p>
</div>
<button onclick="window.open('https://tally.so/r/3XGBad')">Join the beta</button>
<div class="btn-row">
<button onclick="window.open('https://tally.so/r/3XGBad')" class="primary">Join the beta</button>
<button onclick="doNotShowBannerAgain()" class="secondary">Do not show again</button>
</div>
</div>
<!--<details id="seatGuide">
<summary>Seat guide</summary>
Expand Down
24 changes: 22 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ function renderTable(sortedTimeslots, selectedDate, selectedLibrary) {
rowHtml += "</tr>";
table.insertAdjacentHTML("beforeend", rowHtml);

document.getElementById('banner').style.display = 'flex';
// Show the banner if the user has not hidden it yet
if (!localStorage.getItem("hideBanner")) {
document.getElementById('banner').style.display = 'flex';
}
}

// Show the table after rendering
Expand Down Expand Up @@ -306,14 +309,26 @@ document

const selectedDate = new Date(document.getElementById("date").value);
const rNumberField = document.getElementById("rNumber");
document.getElementById("rNumber").value = rNumberField.value.trim().toLowerCase();
let rNumber = rNumberField.value;

// Check if the r-number starts with 'r' and add it if it doesn't
if (!rNumber.startsWith("r")) {
if (!rNumber.startsWith("r") && !rNumber.startsWith("u")) {
rNumber = `r${rNumber}`;
rNumberField.value = rNumber;
}

if (rNumber.match(/[ur]\d{7}/) === null) {
alert("Invalid username (r-number/u-number). Make sure you entered it exactly as it is on your KU Leuven card");
return;
}

if (rNumber.match(/[u]\d{7}/)) {
alert(
"Warning: You entered a U-number. We were unable to test the functionality of this tool with U-numbers. Please proceed with caution."
);
}

// Check if the checkbox is checked
const rememberRNumber = document.getElementById("rememberRNumber").checked;

Expand Down Expand Up @@ -345,3 +360,8 @@ document
fetchButton.disabled = false;
});
});

function doNotShowBannerAgain() {
document.getElementById("banner").style.display = "none";
localStorage.setItem("hideBanner", true);
}
Loading

0 comments on commit c460a9f

Please sign in to comment.