Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielDavis05 committed Oct 16, 2023
1 parent 09a8a23 commit f8ef7dc
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 25 deletions.
2 changes: 1 addition & 1 deletion leaderboard/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<link rel="stylesheet" href="/style/leaderboard/leaderboard.css">

<!-- Load in page specific CSS -->
<link rel="stylesheet" href="/style/login.css">
<link rel="stylesheet" href="/style/leaderboard/login.css">

<!--Scripts re-used across stogacs.club -->
<script src="/scripts/utils.js"></script>
Expand Down
6 changes: 5 additions & 1 deletion leaderboard/logout.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1 class="center-text" id="logout-title">Please wait</h1>
title = document.getElementById("logout-title");
subtitle = document.getElementById("logout-subtitle");
homeHref = document.getElementById("logout-home");
if (window.location.search == "?all") {
if (window.location.search.includes("?all")) {
fetch("https://shekels.mrsharick.com/me/logout?discordAuth=" + getCookie("discordAuth") + "&all=true", {
method: "POST",
headers: {
Expand Down Expand Up @@ -65,5 +65,9 @@ <h1 class="center-text" id="logout-title">Please wait</h1>
homeHref.href = "/";
homeHref.style.display = "block";
}
if(window.location.search.includes("message")) {
let message = window.location.search.split("message=")[1];
subtitle.innerText = decodeURIComponent(message);
}
</script>
</body>
14 changes: 9 additions & 5 deletions leaderboard/onboarding/claim.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script src="/scripts/navbar.js"></script>

<!-- Load in page specific CSS -->
<link rel="stylesheet" href="/style/leaderboard.css">
<link rel="stylesheet" href="/style/leaderboard/leaderboard.css">
<link rel="stylesheet" href="/style/tooltips.css">

<!-- Load in page specific scripts -->
Expand Down Expand Up @@ -74,12 +74,16 @@ <h1 class="pure-u-1 center-text" style="margin-top: 0px;">Link to Discord</h1>
</script>
</select>
</div>
<div class="pure-controls">
<button id="claim-button" type="button" class="pure-button pure-button-primary"
onclick="submitData()">Claim</button>
</div>

</fieldset>
</form>
<div class="pure-g">
<div class="pure-controls center-text">
<a href="../logout.html"><button id="signout-button" type="button" class="pure-button">Sign Out</button></a>
<button id="claim-button" type="button" class="pure-button pure-button-primary"
onclick="submitData()">Claim</button>
</div>
</div>
<div class="pure-u-1-12"><!-- formatting div POST--></div>

</section>
Expand Down
2 changes: 1 addition & 1 deletion leaderboard/shop/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h3><p>Summary</p></h3>
<img style="padding:30px;">
<div>
<p id="account-description" class="center-text">Loading your account info...</p>
<a class="button-container" href="./past.html" target="_blank">
<a class="button-container" href="./past.html">
<button type="button" class="pure-button pure-button-primary">
<div class="button-content">
<p class="button-text">View my items</p>
Expand Down
22 changes: 12 additions & 10 deletions scripts/leaderboard/onboarding.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
document.addEventListener("DOMContentLoaded", async function () {
await verifyUser().then(userInfo => {
if (userInfo != null) {
if (userInfo.name != null) {
window.location.href = "/leaderboard";
}
} else {
window.location.href = "/401";
}
});
// await verifyUser().then(userInfo => {
// if (userInfo != null) {
// if (userInfo.name != null) {
// window.location.href = "/leaderboard";
// }
// } else {
// window.location.href = "/401";
// }
// });

});

Expand All @@ -30,11 +30,13 @@ function submitData() {
return response.json();
})
.then(result => {
// if code is 200, redirect to leaderboard
console.log(result)
if (result.success) {
window.location.href = "/leaderboard";
} else {
if (result.logout) {
window.location.href = "/leaderboard/logout.html?message=" + encodeURIComponent("The server wasn't able to verify your Discord account. Please sign in again via Discord or contact a club officer for assistance.");
}
document.getElementById("error-display").innerHTML = result.message;
}
document.getElementById("loader").style.display = "none";
Expand Down
13 changes: 9 additions & 4 deletions scripts/leaderboard/purchases.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,17 @@ function getPurchases(userInfo) {


document.addEventListener("DOMContentLoaded", async function() {
let userInfo = await verifyUser();
if (userInfo != null) {
if (userInfo.name == null) {
let userInfo;
await verifyUser().then(userInfo => {
if (userInfo != null) {
if (userInfo.name == null) {
window.location.href = "/leaderboard/onboarding/claim.html";
}
} else {
window.location.href = "/401";
}
}
userInfo = userInfo;
});
let chart = document.getElementById("purchases-table");
chart.innerHTML = `<p class="center-text">Now Loading...</p>`;
getPurchases(userInfo);
Expand Down
6 changes: 3 additions & 3 deletions scripts/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const knownVersion = 'MS41LjA';
const knownVersion = 'Mi4wLjA';

function getCookie(name) {
const cookies = document.cookie.split(';');
Expand Down Expand Up @@ -28,7 +28,7 @@ function getLoginDetails() {

if (access_token != null) {
setCookie('discordAuth', access_token, 7);
window.location.href = window.location.href.split('?')[0]; // go back but remove token
window.location.href = window.location.href.split('?')[0];
}
}

Expand All @@ -38,7 +38,7 @@ async function verifyUser() {
try {
const response = await fetch(`https://shekels.mrsharick.com/discord/user?token=${access_token}`);
const data = await response.json();
if (response.status == 404) {
if (response.status != 200) {
deleteCookie('discordAuth');
return null;
}
Expand Down
5 changes: 5 additions & 0 deletions style/leaderboard/leaderboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
/* Ensure the loader is on top */
}

#signout-button {
background: rgb(202, 60, 60);
color: white;
}

.admin-num-input {
max-width: 6rem;
background: transparent;
Expand Down

0 comments on commit f8ef7dc

Please sign in to comment.