Skip to content

Commit e1917ed

Browse files
mobile friendly popup
1 parent 67c831a commit e1917ed

File tree

2 files changed

+49
-45
lines changed

2 files changed

+49
-45
lines changed

app.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,51 +24,51 @@ function isNumeric(str) {
2424
} // from https://stackoverflow.com/a/175787
2525

2626
signInBtn.addEventListener("click", () => {
27-
const provider = new firebase.auth.GoogleAuthProvider();
28-
auth.signInWithPopup(provider)
29-
.then((result) => {
30-
const testing = true;
31-
32-
const user = result.user;
33-
const email = user.email;
34-
35-
console.log(email);
36-
if (testing === false) {
37-
if (!email.endsWith("@student.sbhs.nsw.edu.au") || !isNumeric(email[0])) {
38-
alert("Please use your @student.sbhs.nsw.edu.au account to prevent double accounts.");
39-
auth.signOut();
40-
return;
27+
const provider = new firebase.auth.GoogleAuthProvider();
28+
auth.signInWithPopup(provider)
29+
.then((result) => {
30+
const testing = true;
31+
32+
const user = result.user;
33+
const email = user.email;
34+
35+
console.log(email);
36+
if (testing === false) {
37+
if (!email.endsWith("@student.sbhs.nsw.edu.au") || !isNumeric(email[0])) {
38+
alert("Please use your [studentID]@student.sbhs.nsw.edu.au account to help prevent double accounts.");
39+
auth.signOut();
40+
return;
41+
}
4142
}
42-
}
4343

44-
// Only create the user record if it doesn't exist
45-
const uid = user.uid;
46-
const userRef = db.ref("users/" + uid);
47-
48-
userRef.once("value").then((snapshot) => {
49-
if (!snapshot.exists()) {
50-
userRef.set({
51-
name: user.displayName,
52-
email: user.email,
53-
score: 0,
54-
opponent: null,
55-
currentGameUrl: null
56-
}).then(() => {
57-
loadLeaderboard(); // Only call it after user is added
58-
});
59-
} else {
60-
loadLeaderboard(); // Call immediately if already exists
61-
}
44+
// Only create the user record if it doesn't exist
45+
const uid = user.uid;
46+
const userRef = db.ref("users/" + uid);
47+
48+
userRef.once("value").then((snapshot) => {
49+
if (!snapshot.exists()) {
50+
userRef.set({
51+
name: user.displayName,
52+
email: user.email,
53+
score: 0,
54+
opponent: null,
55+
currentGameUrl: null
56+
}).then(() => {
57+
loadLeaderboard(); // Only call it after user is added
58+
});
59+
} else {
60+
loadLeaderboard(); // Call immediately if already exists
61+
}
62+
});
63+
64+
userInfo.innerText = `Signed in as ${user.displayName}`;
65+
signInBtn.style.display = "none";
66+
afterSignIn(user)
67+
})
68+
.catch((error) => {
69+
console.error("Sign-in error:", error);
70+
alert("Sign-in failed.");
6271
});
63-
64-
userInfo.innerText = `Signed in as ${user.displayName}`;
65-
signInBtn.style.display = "none";
66-
afterSignIn(user)
67-
})
68-
.catch((error) => {
69-
console.error("Sign-in error:", error);
70-
alert("Sign-in failed.");
71-
});
7272
});
7373

7474
auth.onAuthStateChanged((user) => {

style.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,22 +328,26 @@ a:active {
328328
background-color: #1e1e1e;
329329
color: white;
330330
margin: 10% auto;
331-
padding: 1rem 2rem;
331+
padding: 1rem 1.2rem; /* Slightly smaller padding on small screens */
332332
border-radius: 8px;
333333
width: 90%;
334334
max-width: 450px;
335335
position: relative;
336+
box-sizing: border-box;
337+
overflow-y: auto;
338+
max-height: 90vh; /* Prevent it from going off screen */
336339
}
337340

338341
#popup-close {
339342
position: absolute;
340343
top: 0.5rem;
341344
right: 0.8rem;
342-
font-size: 1.2rem;
345+
font-size: 1.5rem;
343346
cursor: pointer;
347+
padding: 0.25rem 0.5rem; /* Tappable area */
348+
line-height: 1;
344349
}
345350

346-
347351
.popupImage {
348352
width: 100%;
349353
height: auto;

0 commit comments

Comments
 (0)