forked from useclassplay/useclassplay.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.html
147 lines (131 loc) · 5.21 KB
/
profile.html
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Classplay Profile</title>
<link rel="shortcut icon" href="img/favicon.png" type="image/x-icon">
<link rel="stylesheet" href="style.css">
<link href="assets/fontawesome/css/all.css" rel="stylesheet" />
</head>
<body>
<style>
body {
font-family: Arial, sans-serif;
}
nav ul {
list-style-type: none;
padding: 0;
}
nav ul li {
display: inline;
margin-right: 15px;
}
</style>
<nav>
<ul>
<li class="title"><a href="index.html" style="font-weight: 560;">Classplay</a></li>
<li><a href="profile.html" class="lesspadding" style="margin-right: -30px;"><i class="fa-solid fa-user"></i></a></li>
<li><a href="chat/"><i class="fa-solid fa-message"></i>Chatroom</a></li>
<li><a href="movies/"><i class="fa-solid fa-tv"></i>Movies</a></li>
<li><a href="p.html"><i class="fa-solid fa-search"></i>Search</a></li>
<li><a href="s.html"><i class="fa-solid fa-music"></i>Sounds</a></li>
<li><a href="apps.html"><i class="fa-solid fa-folder"></i>Apps</a></li>
<li><a href="g.html"><i class="fa-solid fa-gamepad"></i>Games</a></li>
</ul>
</nav>
<br><br><br><br>
<!-- Register Form -->
<center>
<div id="register">
<h1>Register an Account</h1>
<input type="text" id="register-email" placeholder="Email"><br><br>
<input type="password" id="register-password" placeholder="Password"><br><br>
<button onclick="registerUser()">Register</button>
<br><br><br>
<p>Already have an account? <a onclick="displayLogin()">Login</a></p>
</div>
</center>
<!-- Login Form -->
<center>
<div id="login" style="display: none;">
<h1>Login to an Account</h1>
<input type="text" id="login-email" placeholder="Email"><br><br>
<input type="password" id="login-password" placeholder="Password"><br><br>
<button onclick="loginUser()">Login</button>
<br><br><br>
<p>Need an account? <a onclick="displayRegister()">Register</a></p>
</div>
</center>
<!-- Logout Button -->
<center>
<div id="logout" style="display: none;">
<h2>Welcome!</h2>
<button onclick="logoutUser()">Logout</button>
</div>
</center>
main
<script type="module">
import { Client, Account } from 'appwrite';
=======
<script src="main.js"></script>
<script src="profile.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.0.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.0.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.0.0/firebase-firestore.js"></script>
main
// Initialize Appwrite client
const client = new Client();
client
.setEndpoint('classplay-login1') // Replace with your Appwrite endpoint
.setProject('classplay-login1'); // Replace with your project ID
const account = new Account(client);
// Display Login Form
function displayLogin() {
document.getElementById('register').style.display = 'none';
document.getElementById('login').style.display = 'block';
}
// Display Register Form
function displayRegister() {
document.getElementById('login').style.display = 'none';
document.getElementById('register').style.display = 'block';
}
// Register User
async function registerUser() {
const email = document.getElementById('register-email').value;
const password = document.getElementById('register-password').value;
try {
await account.create('unique()', email, password);
alert('Registration successful! You can now log in.');
displayLogin();
} catch (error) {
alert('Error: ' + error.message);
}
}
// Login User
async function loginUser() {
const email = document.getElementById('login-email').value;
const password = document.getElementById('login-password').value;
try {
await account.createEmailSession(email, password);
alert('Login successful!');
document.getElementById('login').style.display = 'none';
document.getElementById('logout').style.display = 'block';
} catch (error) {
alert('Error: ' + error.message);
}
}
// Logout User
async function logoutUser() {
try {
await account.deleteSession('current');
alert('Logged out successfully.');
document.getElementById('logout').style.display = 'none';
displayLogin();
} catch (error) {
alert('Error: ' + error.message);
}
}
</script>
</body>
</html>