-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
110 lines (97 loc) · 4.2 KB
/
index.html
File metadata and controls
110 lines (97 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>CoolMathTime - Login / Sign Up</title>
<link rel="stylesheet" href="style.css">
<script src="https://houselearning.org/cookiebanner.js"></script>
<script src="https://houselearning.org/feedback.js"></script>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script type="module" src="https://www.houselearning.org/also.js"></script>
</head>
<body>
<nav class="navbar">
<div class="navbar-content">
<a href="https://houselearning.org/home/#">Home</a>
<a href="https://houselearning.org/home/math-page.html#">Math Games</a>
<a href="https://houselearning.org/home/science-page.html#">Science Fun</a>
<a href="https://houselearning.org/home/computer-science-page.html#">Coding Challenges</a>
</div>
</nav>
<main class="container">
<div class="auth-card">
<h2 id="form-title">Login</h2>
<p id="error-message" class="error-message"></p>
<form id="auth-form">
<div class="input-group">
<label for="email">Email:</label>
<input type="email" id="email" required>
</div>
<div class="input-group">
<label for="password">Password:</label>
<input type="password" id="password" required>
</div>
<!-- reCAPTCHA for Sign Up only -->
<div id="recaptcha-container" style="margin-top:10px; display:none;">
<div class="g-recaptcha" data-sitekey="6LeNBUwsAAAAAMwDhp2LCD6iy_uDg0exFUxqNfFi"></div>
</div>
<button type="submit" id="submit-button">Log In</button>
<button type="button" id="google-signin-button" class="google-signin-button">
<img src="img/g-logo.png" alt="Google logo" style="width:18px;height:18px;margin-right:10px;vertical-align:middle;">
Sign in with Google
</button>
<button type="button" id="github-signin-button" class="github-signin-button">
<img src="img/octoicon.svg" alt="GitHub logo" style="width:18px;height:18px;margin-right:10px;vertical-align:middle;">
Sign in with GitHub
</button>
</form>
<p class="toggle-link">
Don't have an account?
<a href="#" id="toggle-auth">Sign Up</a>
</p>
<div id="success-message" class="success-message" style="display: none;"></div>
</div>
</main>
<script src="https://www.gstatic.com/firebasejs/9.6.10/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.6.10/firebase-auth-compat.js"></script>
<script src="auth.js"></script>
<script>
// Grab existing elements
const toggleAuthLink = document.getElementById("toggle-auth");
const recaptchaContainer = document.getElementById("recaptcha-container");
//const formTitle = document.getElementById("form-title"); // <-- use existing element, no duplicate declaration
// Toggle between Login and Sign Up
toggleAuthLink.addEventListener("click", (e) => {
e.preventDefault();
if(formTitle.textContent === "Login") {
// Switch to Sign Up
formTitle.textContent = "Sign Up";
toggleAuthLink.textContent = "Log In";
recaptchaContainer.style.display = "block"; // show reCAPTCHA
} else {
// Switch back to Login
formTitle.textContent = "Login";
toggleAuthLink.textContent = "Sign Up";
recaptchaContainer.style.display = "none"; // hide reCAPTCHA
}
});
// Form submission
authForm.addEventListener("submit", function(e) {
e.preventDefault();
errorMessage.textContent = "";
if(formTitle.textContent === "Sign Up") {
// Check reCAPTCHA for Sign Up
const captchaResponse = grecaptcha.getResponse();
if(!captchaResponse) {
errorMessage.textContent = "Please complete the CAPTCHA to Sign Up.";
errorMessage.className = "error-message";
return; // stop submission
}
}
// Continue with normal login or sign-up logic
console.log("Form submitted for", formTitle.textContent);
});
</script>
</body>
</html>