-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
141 lines (119 loc) · 6.47 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Primary Meta Tags -->
<title>GDSC-BIT - AI & ML Game - PokéPrompt | Join GDSC-BIT Chapter Now!</title>
<link rel="icon" type="image/png" href="https://cdn.discordapp.com/attachments/1152318832602525706/1153142796186816583/32eb230b326ee3c76e64f619a06f6ebb_1-min.png" />
<meta name="title" content="GDSC-BIT - AI & ML Game - PokéPrompt | Join GDSC-BIT Chapter Now!" />
<meta name="description" content="GDSC-BIT - AI & ML Game - PokéPrompt: Write the best prompts and get a chance to win exciting prizes!" />
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:url" content="https://bit-gdsc.github.io/PokePrompt/" />
<meta property="og:title" content="GDSC-BIT - AI & ML Game - PokéPrompt | Join GDSC-BIT Chapter Now!" />
<meta property="og:description" content="GDSC-BIT - AI & ML Game - PokéPrompt: Write the best prompts and get a chance to win exciting prizes!" />
<meta property="og:image" content="https://cdn.discordapp.com/attachments/1152318832602525706/1153140926206726214/bannner-min.png" />
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content="https://bit-gdsc.github.io/PokePrompt/" />
<meta property="twitter:title" content="GDSC-BIT - AI & ML Game - PokéPrompt | Join GDSC-BIT Chapter Now!" />
<meta property="twitter:description" content="GDSC-BIT - AI & ML Game - PokéPrompt: Write the best prompts and get a chance to win exciting prizes!" />
<meta property="twitter:image" content="https://cdn.discordapp.com/attachments/1152318832602525706/1153140926206726214/bannner-min.png" />
<!-- gfonts -->
<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=VT323&display=swap" rel="stylesheet">
<!-- nes.css -->
<link href="https://unpkg.com/nes.css@latest/css/nes.min.css" rel="stylesheet" />
<!-- custom styles -->
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="formbold-main-wrapper">
<!-- Author: FormBold Team -->
<!-- Learn More: https://formbold.com -->
<div class="formbold-form-wrapper">
<div class="full-width logo-div">
<img src="https://cdn.discordapp.com/attachments/1152318832602525706/1152580696779530240/title.png" class="logo">
</div>
<form id="pokeForm">
<!-- Added an ID to the form for easier access in JavaScript -->
<div class="formbold-input-flex full-width">
<div class="nes-field">
<label for="name">Your name</label>
<input type="text" id="name" name="name" class="nes-input" required>
</div>
</div>
<div class="formbold-input-flex full-width">
<div class="nes-field">
<label for="email">Email</label>
<input type="email" id="email" name="email" class="nes-input" required>
</div>
</div>
<div class="formbold-mb-3">
<label for="member">Do you study in Bengal Institute of Technology (BIT)?</label>
<div class="nes-select">
<select id="member" name="member" required>
<option value="" disabled selected hidden>Select...</option>
<option value="true">Yes</option>
<option value="false">No</option> <!-- Changed "NO" to "No" for consistency -->
</select>
</div>
</div>
<center>
<button class="formbold-btn nes-btn is-warning" type="submit">Start Game!</button>
</center>
</form>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#pokeForm");
form.addEventListener("submit", function(e) {
e.preventDefault();
const formData = new FormData(form);
const data = {};
formData.forEach((value, key) => {
data[key] = value;
});
console.log(data);
const xhr = new XMLHttpRequest();
const url = "https://gdsctempauth.bitgdsc.repl.co/login";
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
// Set the mode to 'no-cors'
xhr.mode = 'no-cors';
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
console.log(data.name)
const metadata = JSON.stringify({
'level': 1,
'User_json': {
'username': data.name,
'member': data.member,
'total_score': 0,
'level': {
'level_1': {
'score': 0,
'start_time': 'HH:MM:SS DD:MM:YYYY'
}
}
}
})
console.log("Server responded with:", xhr.responseText);
localStorage.setItem("responseData", xhr.responseText);
localStorage.setItem("metadata", metadata);
window.location.href = "./pokeprompt";
} else {
console.error("Server returned an error:", xhr.statusText);
}
}
};
xhr.send(JSON.stringify(data));
});
});
</script>
</body>
</html>