-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathentry.html
150 lines (133 loc) · 3.87 KB
/
entry.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
148
149
150
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<style>
/* Red & Black Themed Background */
body {
background: linear-gradient(135deg, #000000, #8B0000);
color: white;
font-family: Arial, sans-serif;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
/* Login Box */
.login-container {
background: black;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
border: 3px solid red;
width: 90%;
max-width: 400px;
}
/* Label Styling */
label {
font-size: 18px;
font-weight: bold;
display: block;
margin-bottom: 10px;
color: #ff4444;
}
/* Input Styling */
input {
width: 90%;
padding: 12px;
font-size: 16px;
border: 2px solid red;
border-radius: 5px;
background: black;
color: white;
outline: none;
text-align: center;
margin: 5px;
}
input::placeholder {
color: #aaaaaa;
}
/* Button Styling */
button {
width: 100%;
padding: 12px;
margin-top: 15px;
font-size: 18px;
font-weight: bold;
color: white;
background: #ff0000;
border: none;
border-radius: 5px;
cursor: pointer;
transition: 0.3s;
}
button:hover {
background: #cc0000;
}
/* Responsive */
@media (max-width: 500px) {
.login-container {
padding: 20px;
border: 4px solid red;
box-shadow: 0 0 20px rgba(255, 0, 0, 1);
}
label {
font-size: 16px;
}
input {
font-size: 14px;
padding: 10px;
}
button {
font-size: 16px;
padding: 10px;
}
}
</style>
</head>
<body>
<div class="login-container">
<label for="username">Enter Your User-Name</label>
<input type="text" id="username" placeholder="Enter your name">
<button onclick="handleLogin()">Start game</button>
</div>
<script>
async function handleLogin() {
const username = document.getElementById("username").value;
if (!username) {
alert("Please enter a username");
return;
}
try {
const response = await fetch("https://tedx-al.vercel.app/api/user/setUser", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ name: username }),
});
const data = await response.json();
if (data.token) {
localStorage.setItem("token", data.token);
window.location.href = "index-age.html";
} else {
alert(data.error);
}
} catch (error) {
console.error("Error:", error);
alert("Something went wrong");
}
}
// Check if token already exists
window.onload = function () {
if (localStorage.getItem("token")) {
window.location.href = "index-age.html";
}
};
</script>
</body>
</html>