-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
135 lines (110 loc) · 5.24 KB
/
Copy pathindex.html
File metadata and controls
135 lines (110 loc) · 5.24 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/style.css">
<title>Gaming Web App</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Indie+Flower&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Indie+Flower&family=Rubik+Maps&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@200;400&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Sacramento&display=swap" rel="stylesheet">
</head>
<body>
<img class="img-style" src="/images/Play! (1) (1).png" alt="">
<img class="img-style" src="/images/Play! (2).png" alt="">
<img class="img-style" src="/images/Untitled design (1) (1).png" alt="">
<img class="img-style" src="/images/Untitled design (2) (1).png" alt="">
<img class="img-style" src="/images/Untitled design (3) (1).png" alt="">
<img class="img-style" src="/images/Untitled design (4) (1).png" alt="">
<img class="img-style" src="/images/Untitled_design-removebg.png" alt="">
<!-- Sign Up Form -->
<div id="signupForm" class="detailContainer">
<h1 style=" font-size:48px; margin-top:50px; margin-bottom:10px; color:yellow; font-family: 'Sacramento', cursive; font-weight:500">Wonder Play</h1>
<h3 style="padding-bottom:20px;">Sign Up</h3>
<form id="signUp">
Username:<input type="text" name ="user" id="signupUsername" required><br>
Password: <input type="password" name="pass" id="signupPassword" required><br>
<button class="button" type="button" onclick="signup()">Sign Up</button>
<p style="padding-top:30px">Already have an Account? <span style="color:yellow" onclick="existingUser()" class="underline">Log in</span></p>
</form>
</div>
<!-- Login Form -->
<div id="loginForm" class="detailContainer login">
<h1 style=" font-size:48px; margin-top:50px; margin-bottom:10px; color:yellow; font-family: 'Sacramento', cursive; font-weight:500">Wonder Play</h1>
<h3 style="padding-bottom:20px;">Log In</h3>
<form id="login">
Username: <input type="text" id="loginUsername" required><br>
Password: <input type="password" id="loginPassword" required><br>
<button class="button" type="button" onclick="login()">Login</button>
<p style="padding-top:30px; text-align:center">Don't have an Account? <span style="color:yellow" onclick="newUser()" class="underline">Sign Up</span></p>
</form>
</div>
<!-- Home Page -->
<div id="homePage" class="home-page">
<h2>Welcome to Wonder Play!</h2>
<p>Choose a game to play:</p>
<button class="gameButton" onclick="playGame('Game 1')">Play Game 1</button>
<button class="gameButton" onclick="playGame('Game 2')">Play Game 2</button>
<button class="gameButton" onclick="playGame('Game 3')">Play Game 3</button>
<button class="gameButton" onclick="playGame('Game 4')">Play Game 4</button>
</div>
<script>
const UserDetails = JSON.parse(localStorage.getItem('details')) || [];
const UserNames = UserDetails.map((user) => user.username);
function signup() {
const username = document.getElementById('signupUsername').value;
const password = document.getElementById('signupPassword').value;
const UserNames = UserDetails.map((user) => user.username);
if (UserNames.find(ele => username == ele)) {
alert('User Already Exists!');
return;
}
if(!username || !password){
alert('Please enter your username and password');
return;
}
else {
const details = {
username,
password
}
UserDetails.push(details);
localStorage.setItem('details', JSON.stringify(UserDetails));
document.getElementById('signupForm').style.display = 'none';
document.getElementById('loginForm').style.display = 'flex';
}
}
function login() {
const username = document.getElementById('loginUsername').value;
const password = document.getElementById('loginPassword').value;
if (UserDetails.find((user) => {
return user.username === username && user.password === password}
)) {
window.open('/home.html');
} else {
alert('Invalid username or password. Please try again.');
}
}
function playGame(gameName) {
alert('Playing ' + gameName);
}
function existingUser (){
document.getElementById('signupForm').style.display = 'none';
document.getElementById('loginForm').style.display = 'flex';
}
function newUser (){
document.getElementById('signupForm').style.display = 'flex';
document.getElementById('loginForm').style.display = 'none';
}
</script>
</body>
</html>