Skip to content

Commit aa22a7f

Browse files
Add files via upload
1 parent c293f62 commit aa22a7f

5 files changed

Lines changed: 129 additions & 27 deletions

File tree

addon/books.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
6-
<title>My Books - Paper Code</title>
6+
<title>eBooks - Paper Code</title>
77
<link rel="stylesheet" href="../style/books.css">
88
<script src="../scripts/books.js" type="module" defer></script>
99
</head>

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8"/>
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Paper Code </title>
6+
<title>Paper Code Web</title>
77
<link rel="stylesheet" href="style/index_style.css">
88
<script type="module" src="scripts/index.js" defer></script>
99
</head>
@@ -133,4 +133,4 @@ <h1>My Socials</h1>
133133
}
134134
</script>
135135
</body>
136-
</html>
136+
</html>

scripts/experiments.js

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,46 @@ function checkRights() {
6868
Fetch Exps
6969
--------------------------*/
7070

71-
const errorMessages = {
72-
'auth/wrong-password': "Incorrect password. Please try again.",
73-
'auth/user-not-found': "No user found with this email. Please register.",
74-
'auth/invalid-email': "Invalid email format. Please check your email.",
75-
'auth/too-many-requests': "Too many login attempts. Please try again later.",
76-
'auth/network-request-failed':"Network error. Please check your internet connection.",
77-
'auth/operation-not-allowed': "Login operation is not allowed. Please contact support.",
78-
'auth/weak-password': "Weak password. Please use a stronger password.",
79-
'auth/invalid-credential': "Invalid credentials. Please check your email and password."
71+
export const errorMessages = {
72+
'auth/invalid-email': "Invalid email format. Please check your email.",
73+
'auth/user-disabled': "This user account has been disabled.",
74+
'auth/user-not-found': "No user found with this email. Please register.",
75+
'auth/wrong-password': "Incorrect password. Please try again.",
76+
'auth/email-already-in-use': "This email is already registered. Please login or use a different email.",
77+
'auth/operation-not-allowed': "Operation not allowed. Please enable the sign-in method in Firebase Console.",
78+
'auth/weak-password': "Weak password. Please use a stronger password.",
79+
'auth/invalid-credential': "Invalid credentials. Please check and try again.",
80+
'auth/too-many-requests': "Too many login attempts. Please try again later.",
81+
'auth/network-request-failed': "Network error. Please check your connection.",
82+
'auth/requires-recent-login': "Recent login required. Please sign in again before retrying.",
83+
'auth/app-not-authorized': "This app is not authorized to use Firebase Auth with this API key.",
84+
'auth/invalid-verification-code':"Invalid verification code. Please retry.",
85+
'auth/invalid-verification-id': "Invalid verification ID.",
86+
'auth/invalid-persistence-type': "Invalid persistence type. Must be 'local', 'session', or 'none'.",
87+
'auth/unsupported-persistence-type': "This browser does not support the specified persistence.",
88+
'auth/unauthorized-domain': "Domain not authorized for authentication. Add it in Firebase Console.",
89+
'auth/invalid-action-code': "This action code is invalid or expired.",
90+
'auth/expired-action-code': "Action code has expired. Please request a new one.",
91+
'auth/captcha-check-failed': "Captcha verification failed. Try again.",
92+
'auth/code-expired': "SMS code has expired. Please resend the code.",
93+
'auth/invalid-phone-number': "Invalid phone number format.",
94+
'auth/missing-phone-number': "Phone number is required.",
95+
'auth/missing-verification-code':"Verification code is missing.",
96+
'auth/missing-verification-id': "Verification ID is missing.",
97+
'auth/session-cookie-expired': "Session cookie expired. Please sign in again.",
98+
'auth/internal-error': "An internal error occurred. Please try again later.",
99+
'auth/no-such-provider': "No such sign-in provider is associated with this account.",
100+
'auth/account-exists-with-different-credential':
101+
"An account already exists with the same email but different sign-in credentials.",
102+
'auth/invalid-oauth-provider': "Unsupported OAuth provider.",
103+
'auth/popup-blocked': "Popup was blocked by the browser.",
104+
'auth/popup-closed-by-user': "Popup was closed before completing sign-in.",
105+
'auth/user-token-expired': "User credential expired. Please sign in again.",
106+
'auth/null-user': "No user is signed in.",
80107
};
81108

82109

110+
83111
async function fetchExperiments() {
84112
const experimentsRef = collection(db, "experiments");
85113

@@ -102,7 +130,8 @@ async function fetchExperiments() {
102130
return experiments;
103131

104132
} catch (error) {
105-
console.error("Error fetching experiments:", error);
133+
const message = errorMessages[error.code] || error.message;
134+
showModal("Error", message);
106135
return [];
107136
}
108137
}
@@ -129,7 +158,7 @@ function fetchData(){
129158
loading.style.display = "none";
130159
}).catch((err) => {
131160
const message = errorMessages[error.code] || error.message;
132-
showModal("Login Failed", message);
161+
showModal("Error", message);
133162

134163
});
135164

scripts/login.js

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,55 @@ function closeModal() {
4343
const toggle = document.getElementById('togglePassword');
4444
const password = document.getElementById('password');
4545

46-
toggle.addEventListener('click', () => {
47-
const type = password.type === 'password' ? 'text' : 'password';
48-
password.type = type;
46+
toggle.addEventListener('click', () => {
47+
const type = password.type === 'password' ? 'text' : 'password';
48+
password.type = type;
4949

50-
toggle.src = type === 'password' ? '../assets/icons/show_password_icon_close.png' : '../assets/icons/show_password_icon_open.png';
51-
});
50+
toggle.src = type === 'password' ? '../assets/icons/show_password_icon_close.png' : '../assets/icons/show_password_icon_open.png';
51+
});
5252

5353

5454
/* ----------------------------------------------
5555
Login Functionality
5656
------------------------------------------------*/
57-
import { getAuthErrorMessage } from "./component/firebase_errors";
57+
export const errorMessages = {
58+
'auth/invalid-email': "Invalid email format. Please check your email.",
59+
'auth/user-disabled': "This user account has been disabled.",
60+
'auth/user-not-found': "No user found with this email. Please register.",
61+
'auth/wrong-password': "Incorrect password. Please try again.",
62+
'auth/email-already-in-use': "This email is already registered. Please login or use a different email.",
63+
'auth/operation-not-allowed': "Operation not allowed. Please enable the sign-in method in Firebase Console.",
64+
'auth/weak-password': "Weak password. Please use a stronger password.",
65+
'auth/invalid-credential': "Invalid credentials. Please check and try again.",
66+
'auth/too-many-requests': "Too many login attempts. Please try again later.",
67+
'auth/network-request-failed': "Network error. Please check your connection.",
68+
'auth/requires-recent-login': "Recent login required. Please sign in again before retrying.",
69+
'auth/app-not-authorized': "This app is not authorized to use Firebase Auth with this API key.",
70+
'auth/invalid-verification-code':"Invalid verification code. Please retry.",
71+
'auth/invalid-verification-id': "Invalid verification ID.",
72+
'auth/invalid-persistence-type': "Invalid persistence type. Must be 'local', 'session', or 'none'.",
73+
'auth/unsupported-persistence-type': "This browser does not support the specified persistence.",
74+
'auth/unauthorized-domain': "Domain not authorized for authentication. Add it in Firebase Console.",
75+
'auth/invalid-action-code': "This action code is invalid or expired.",
76+
'auth/expired-action-code': "Action code has expired. Please request a new one.",
77+
'auth/captcha-check-failed': "Captcha verification failed. Try again.",
78+
'auth/code-expired': "SMS code has expired. Please resend the code.",
79+
'auth/invalid-phone-number': "Invalid phone number format.",
80+
'auth/missing-phone-number': "Phone number is required.",
81+
'auth/missing-verification-code':"Verification code is missing.",
82+
'auth/missing-verification-id': "Verification ID is missing.",
83+
'auth/session-cookie-expired': "Session cookie expired. Please sign in again.",
84+
'auth/internal-error': "An internal error occurred. Please try again later.",
85+
'auth/no-such-provider': "No such sign-in provider is associated with this account.",
86+
'auth/account-exists-with-different-credential':
87+
"An account already exists with the same email but different sign-in credentials.",
88+
'auth/invalid-oauth-provider': "Unsupported OAuth provider.",
89+
'auth/popup-blocked': "Popup was blocked by the browser.",
90+
'auth/popup-closed-by-user': "Popup was closed before completing sign-in.",
91+
'auth/user-token-expired': "User credential expired. Please sign in again.",
92+
'auth/null-user': "No user is signed in.",
93+
};
94+
5895

5996
const loginBtn = document.getElementById('login_btn');
6097

@@ -75,8 +112,8 @@ function loginUser() {
75112
window.location.href = "../index.html"; // Adjust the URL as needed
76113
})
77114
.catch((error) => {
78-
const msg = getAuthErrorMessage(error.code, error.message);
79-
showModal("Wait!", msg);
115+
const message = errorMessages[error.code] || error.message;
116+
showModal("Wait!", message);
80117
});
81118
}
82119
}

scripts/new.js

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,43 @@ const password = document.getElementById('password');
5555
Register Button Functionality
5656
------------------------------------------------*/
5757

58-
import { getAuthErrorMessage } from "./component/firebase_errors";
58+
export const errorMessages = {
59+
'auth/invalid-email': "Invalid email format. Please check your email.",
60+
'auth/user-disabled': "This user account has been disabled.",
61+
'auth/user-not-found': "No user found with this email. Please register.",
62+
'auth/wrong-password': "Incorrect password. Please try again.",
63+
'auth/email-already-in-use': "This email is already registered. Please login or use a different email.",
64+
'auth/operation-not-allowed': "Operation not allowed. Please enable the sign-in method in Firebase Console.",
65+
'auth/weak-password': "Weak password. Please use a stronger password.",
66+
'auth/invalid-credential': "Invalid credentials. Please check and try again.",
67+
'auth/too-many-requests': "Too many login attempts. Please try again later.",
68+
'auth/network-request-failed': "Network error. Please check your connection.",
69+
'auth/requires-recent-login': "Recent login required. Please sign in again before retrying.",
70+
'auth/app-not-authorized': "This app is not authorized to use Firebase Auth with this API key.",
71+
'auth/invalid-verification-code':"Invalid verification code. Please retry.",
72+
'auth/invalid-verification-id': "Invalid verification ID.",
73+
'auth/invalid-persistence-type': "Invalid persistence type. Must be 'local', 'session', or 'none'.",
74+
'auth/unsupported-persistence-type': "This browser does not support the specified persistence.",
75+
'auth/unauthorized-domain': "Domain not authorized for authentication. Add it in Firebase Console.",
76+
'auth/invalid-action-code': "This action code is invalid or expired.",
77+
'auth/expired-action-code': "Action code has expired. Please request a new one.",
78+
'auth/captcha-check-failed': "Captcha verification failed. Try again.",
79+
'auth/code-expired': "SMS code has expired. Please resend the code.",
80+
'auth/invalid-phone-number': "Invalid phone number format.",
81+
'auth/missing-phone-number': "Phone number is required.",
82+
'auth/missing-verification-code':"Verification code is missing.",
83+
'auth/missing-verification-id': "Verification ID is missing.",
84+
'auth/session-cookie-expired': "Session cookie expired. Please sign in again.",
85+
'auth/internal-error': "An internal error occurred. Please try again later.",
86+
'auth/no-such-provider': "No such sign-in provider is associated with this account.",
87+
'auth/account-exists-with-different-credential':
88+
"An account already exists with the same email but different sign-in credentials.",
89+
'auth/invalid-oauth-provider': "Unsupported OAuth provider.",
90+
'auth/popup-blocked': "Popup was blocked by the browser.",
91+
'auth/popup-closed-by-user': "Popup was closed before completing sign-in.",
92+
'auth/user-token-expired': "User credential expired. Please sign in again.",
93+
'auth/null-user': "No user is signed in.",
94+
};
5995

6096
const registerBtn = document.getElementById('register_btn');
6197

@@ -82,13 +118,13 @@ function registerUser(){
82118
showModal("Registration Successful", "You have successfully registered!");
83119
window.location.href = "../index.html";
84120
}).catch((error) => {
85-
const msg = getAuthErrorMessage(error.code, error.message);
86-
showModal("Wait!", msg);
121+
const message = errorMessages[error.code] || error.message;
122+
showModal("Wait!", message);
87123
});
88124
})
89125
.catch((error) => {
90-
const msg = getAuthErrorMessage(error.code, error.message);
91-
showModal("Ohh!", msg);
126+
const message = errorMessages[error.code] || error.message;
127+
showModal("Wait!", message);
92128
});
93129
}
94130
}

0 commit comments

Comments
 (0)