Skip to content

Commit ee857e4

Browse files
committed
2 parents 291f517 + ddeff05 commit ee857e4

10 files changed

+265
-38
lines changed

AA_csa.md

-6
This file was deleted.

AB_csp.md

-6
This file was deleted.

AC_csse.md

-6
This file was deleted.

AD_compsci.md

-6
This file was deleted.

BA_about.md

-9
This file was deleted.

BA_signin.html

+208
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
---
2+
layout: base
3+
permalink: /sign_in/
4+
title: Sign In
5+
search_exclude: true
6+
---
7+
8+
<style>
9+
body {
10+
width: 100%;
11+
display: flex;
12+
justify-content: center;
13+
}
14+
15+
.tabs {
16+
margin: 0 auto;
17+
margin: 10x;
18+
display: flex;
19+
justify-content: space-around;
20+
width: 300px;
21+
background-color: #3498db;
22+
border-radius: 5px;
23+
overflow: hidden;
24+
-moz-border-radius: 0px;
25+
-webkit-border-radius: 5px 5px 0px 0px;
26+
border-radius: 5px 5px 0px 0px;
27+
}
28+
29+
.tab {
30+
padding: 15px;
31+
color: #000000;
32+
cursor: pointer;
33+
transition: background-color 0.3s ease;
34+
}
35+
36+
.tab:hover {
37+
background-color: #2980b9;
38+
}
39+
40+
.tab-content {
41+
margin: 0 auto;
42+
display: none;
43+
padding: 20px;
44+
box-sizing: border-box;
45+
width: 300px;
46+
border: 1px solid #3498db;
47+
-moz-border-radius: 0px;
48+
-webkit-border-radius: 0px 0px 5px 5px;
49+
border-radius: 0px 0px 5px 5px;
50+
background-color: #070707;
51+
}
52+
53+
#login-tab-content {
54+
display: block;
55+
}
56+
57+
input {
58+
display: block;
59+
margin : 0 auto;
60+
border: 0;
61+
padding: 1em;
62+
}
63+
64+
textarea:focus, input:focus{
65+
outline: none;
66+
}
67+
68+
.login-button {
69+
display: block;
70+
margin : 0 auto;
71+
border-color: white !important;
72+
}
73+
</style>
74+
</head>
75+
<body>
76+
77+
<div class="tabs">
78+
<div class="tab" onclick="showTab('login-tab')">Login</div>
79+
<div class="tab" onclick="showTab('signup-tab')">Sign Up</div>
80+
</div>
81+
82+
<div id="login-tab-content" class="tab-content">
83+
<h2 style="text-align: center;">Login</h2>
84+
<form>
85+
<input type="text" id="email" name="email" placeholder="email" required>
86+
<br>
87+
<input type="password" id="password" name="password" placeholder="password" required>
88+
<br>
89+
<button id="logInButton" type="submit" class="login-button" onclick="logIn()">Login</button>
90+
</form>
91+
</div>
92+
93+
<div id="signup-tab-content" class="tab-content">
94+
<h2 style="text-align: center;">Sign Up</h2>
95+
<form>
96+
<input type="text" id="new-name" name="name" placeholder="name" required>
97+
<br>
98+
<input type="text" id="new-email" name="email" placeholder="email" required>
99+
<br>
100+
<input type="password" id="new-password" name="password" placeholder="password" required>
101+
<br>
102+
<input type="date" id="new-dob" name="dob" required>
103+
<br>
104+
<button id="signUpButton" type="submit" class="login-button" onclick="signUp()">Sign Up</button>
105+
</form>
106+
</div>
107+
108+
<script>
109+
const signup_url = 'http://localhost:8085/api/person/post?';
110+
const login_url = 'http://localhost:8085/authenticate';
111+
112+
function showTab(tabId) {
113+
// Hide all tab contents
114+
document.querySelectorAll('.tab-content').forEach(tab => tab.style.display = 'none');
115+
116+
// Show the selected tab content
117+
document.getElementById(tabId + '-content').style.display = 'block';
118+
}
119+
120+
function signUp() {
121+
let email = document.getElementById("new-email").value;
122+
let password = document.getElementById("new-password").value;
123+
let name = document.getElementById("new-name").value;
124+
let dob = document.getElementById("new-dob").value;
125+
126+
const params = {
127+
"email": email,
128+
"password": encodeURIComponent(password),
129+
"name": encodeURIComponent(name),
130+
"dob": encodeURIComponent(dob)
131+
};
132+
133+
console.log("sign up fetch url: " + signup_url + new URLSearchParams(params));
134+
135+
fetch(signup_url + new URLSearchParams(params), {
136+
method: 'POST',
137+
})
138+
.then(response => response.json())
139+
.then(data => console.log(data))
140+
.catch(error => console.error('Error:', error));
141+
}
142+
143+
function logIn() {
144+
let email = document.getElementById("email").value;
145+
let password = document.getElementById("password").value;
146+
147+
const params = {
148+
email: email,
149+
password: password
150+
};
151+
152+
console.log("login fetch url: " + login_url);
153+
console.log("body: " + JSON.stringify(params))
154+
fetch(login_url, {
155+
method: 'POST',
156+
headers: {
157+
'Content-Type': 'application/json',
158+
},
159+
body: JSON.stringify(params),
160+
})
161+
.then(response => response.json())
162+
.then(data => {
163+
console.log(data);
164+
if (data.status==200) {
165+
window.location.replace("/stats.html");
166+
} else {
167+
console.log("bad email and password");
168+
}
169+
})
170+
.catch(error => console.error('Error:', error));
171+
}
172+
173+
function logInXML() {
174+
let email = document.getElementById("email").value;
175+
let password = document.getElementById("password").value;
176+
177+
const loginData = {
178+
email: email,
179+
password: password
180+
};
181+
182+
console.log("login fetch url: " + login_url);
183+
184+
const xhr = new XMLHttpRequest();
185+
xhr.open('POST', login_url, true);
186+
xhr.setRequestHeader('Content-Type', 'application/json');
187+
188+
xhr.onreadystatechange = function () {
189+
if (xhr.readyState === XMLHttpRequest.DONE) {
190+
if (xhr.status === 200) {
191+
const data = JSON.parse(xhr.responseText);
192+
console.log(data);
193+
if (data.status == 200) {
194+
window.location.replace("/stats.html");
195+
} else {
196+
console.log("bad email and password");
197+
}
198+
} else {
199+
console.error('Error:', xhr.statusText);
200+
}
201+
}
202+
};
203+
204+
xhr.send(JSON.stringify(loginData));
205+
}
206+
</script>
207+
208+

_config.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
title: Nighthawk-Pages
1+
title: HTML/JavaScript Lesson
22
description: "August 2023 to June 2024"
3-
owner_name: Tirth Thakkar
4-
github_username: Tirth-Thakkar
5-
github_repo: "Nighthawk-Pages"
6-
baseurl: "/Nighthawk-Pages"
3+
owner_name: CSA_AI
4+
github_username: CSA_AI
5+
github_repo: "Lesson_Frontend"
6+
baseurl: "/Lesson_Frontend"
77
remote_theme: jekyll/minima
88
minima:
99
social_links:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"---\n",
8+
"toc: true\n",
9+
"comments: true\n",
10+
"layout: notebook\n",
11+
"title: User Profile JavaScript/HTML Lesson\n",
12+
"description: The College Board testing language is Pseudo Code. Pseudo mean kind-of language that we will compare to Python.\n",
13+
"courses: { csp: {week: 19} }\n",
14+
"type: hacks\n",
15+
"---"
16+
]
17+
},
18+
{
19+
"cell_type": "markdown",
20+
"metadata": {},
21+
"source": [
22+
"# User Profile JavaScript/HTML Lesson"
23+
]
24+
},
25+
{
26+
"cell_type": "markdown",
27+
"metadata": {},
28+
"source": [
29+
"## "
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"metadata": {},
36+
"outputs": [],
37+
"source": []
38+
}
39+
],
40+
"metadata": {
41+
"kernelspec": {
42+
"display_name": "java",
43+
"language": "java",
44+
"name": "java"
45+
},
46+
"language_info": {
47+
"name": "java"
48+
}
49+
},
50+
"nbformat": 4,
51+
"nbformat_minor": 2
52+
}
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)