-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstage3.html
More file actions
280 lines (243 loc) · 7.79 KB
/
Copy pathstage3.html
File metadata and controls
280 lines (243 loc) · 7.79 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Disappearing Prompt</title>
<style>
/* Base Reset */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(to right, #141e30, #243b55);
color: #333;
min-height: 100vh;
}
/* Header Styling */
header {
width: 100%;
max-width: 100vw;
height: 80px;
background: rgba(6, 17, 31, 0.85);
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px;
overflow: hidden;
}
header img {
height: 60px;
width: auto;
display: block;
}
/* Container */
.container {
max-width: 800px;
margin: 100px auto 30px; /* space below header */
background: white;
padding: 30px;
border-radius: 15px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}
/* Heading */
h1 {
text-align: center;
margin-bottom: 25px;
font-size: 2rem;
color: #2d3748;
}
/* Timer */
#timer {
font-size: 1.2rem;
text-align: center;
margin-bottom: 15px;
font-weight: bold;
color: #ff5e5e;
}
/* Prompt Box */
#promptText {
background: #edf2f7;
padding: 15px 20px;
border-radius: 10px;
font-size: 1.1rem;
margin-bottom: 20px;
min-height: 80px;
transition: all 0.3s ease-in-out;
}
/* Textarea */
textarea {
width: 100%;
padding: 12px 15px;
font-size: 1rem;
border: 1px solid #cbd5e0;
border-radius: 8px;
margin-bottom: 20px;
resize: vertical;
min-height: 100px;
transition: border 0.2s;
}
textarea:focus {
outline: none;
border-color: #4299e1;
}
/* Button */
button {
display: block;
margin: auto;
padding: 10px 30px;
font-size: 1rem;
background: #4299e1;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
transition: background 0.2s ease;
}
button:hover {
background: #2b6cb0;
}
/* Score Display */
#score {
margin-top: 20px;
font-size: 1.3rem;
text-align: center;
font-weight: bold;
color: #2f855a;
}
/* Responsive */
@media (max-width: 600px) {
.container {
padding: 20px;
}
h1 {
font-size: 1.5rem;
}
textarea {
font-size: 0.95rem;
}
}
</style>
</head>
<body>
<!-- Header -->
<header>
<img src="./images/logo1.png" alt="Left">
<img src="./images/logo2.png" alt="Center">
<img src="./images/logo3.png" alt="Right">
</header>
<!-- Main Container -->
<div class="container">
<h1>Stage 3: Disappearing Prompt</h1>
<div id="timer">Reading Time: 10s</div>
<div id="promptText" oncopy="return false"></div>
<textarea id="userInput" placeholder="Type the original prompt here..." style="display: none;"></textarea>
<button id="submitBtn" onclick="checkAnswer()" style="display: none;">Submit</button>
<div id="score"></div>
<button onclick="goBack()">⬅ Back</button>
</div>
<script>
function goBack() {
if (window.history.length > 1) {
window.history.back();
} else {
window.location.href = "login.html"; // fallback page
}
}
const prompts = [
"Artificial intelligence is transforming industries by automating tasks, analyzing data, and improving decisions in real-time complex business environments worldwide every single day.",
"A student designs a robot using machine learning to identify ocean plastics, separate them from seaweed, and clean beaches with maximum safety automatically.",
"An AI-powered translator converts any spoken language instantly at global conferences, helping people communicate easily across countries without barriers or delays in real-time.",
"A wearable device monitors vital signs continuously, predicts possible health issues using neural networks, and sends alerts to doctors before emergencies arise daily.",
"Self-driving cars use advanced AI vision systems and predictive algorithms to navigate traffic, avoid hazards, and optimize energy consumption in busy cities worldwide."
];
const fullPrompt = prompts[Math.floor(Math.random() * prompts.length)];
const words = fullPrompt.split(" ");
const promptText = document.getElementById("promptText");
const timer = document.getElementById("timer");
const inputBox = document.getElementById("userInput");
const submitBtn = document.getElementById("submitBtn");
const scoreDisplay = document.getElementById("score");
let currentWords = [...words];
let vanishInterval;
let readingTime = 10;
// Display full prompt
promptText.textContent = fullPrompt;
// Countdown timer
const readingCountdown = setInterval(() => {
readingTime--;
timer.textContent = `Reading Time: ${readingTime}s`;
if (readingTime === 0) {
clearInterval(readingCountdown);
startVanishProcess();
}
}, 1000);
function startVanishProcess() {
inputBox.style.display = "block";
submitBtn.style.display = "block";
timer.textContent = "Prompt is vanishing...";
vanishInterval = setInterval(() => {
const remaining = currentWords.filter(w => w !== "___");
if (remaining.length <= 3) {
clearInterval(vanishInterval);
timer.textContent = "Submit your response!";
return;
}
let index;
do {
index = Math.floor(Math.random() * currentWords.length);
} while (currentWords[index] === "___");
currentWords[index] = "___";
promptText.textContent = currentWords.join(" ");
}, 1000);
}
function checkAnswer() {
clearInterval(vanishInterval);
const userText = inputBox.value.trim().toLowerCase();
const originalWords = fullPrompt.toLowerCase().split(" ");
const userWords = userText.split(" ");
let matched = 0;
for (let i = 0; i < Math.min(userWords.length, originalWords.length); i++) {
if (userWords[i] === originalWords[i]) {
matched++;
}
}
const score = Math.round((matched / originalWords.length) * 100);
scoreDisplay.innerHTML = `Your Score: <strong>${score}%</strong>`;
// Save stage3 score to localStorage in case submission fails
localStorage.setItem("stage3_score", score.toString());
// Collect all data from localStorage
const data = {
name: localStorage.getItem("user_name") || "",
branch: localStorage.getItem("user_branch") || "",
rollNo: localStorage.getItem("user_rollNo") || "",
year: localStorage.getItem("user_year") || "",
phoneNumber: localStorage.getItem("user_phone") || "",
stage1_score: localStorage.getItem("stage1_score") || "0",
stage2_score: localStorage.getItem("stage2_score") || "0",
stage3_score: score.toString()
};
// Build query string
const query = new URLSearchParams(data).toString();
// 🚨 Replace this with your actual Google Apps Script Web App URL
const scriptURL = "https://script.google.com/macros/s/AKfycbxglVz9l7RzgEJVPyZeB1azWd2jTu7R_CIbjYr_EC5lkDoFvCbRvp3_SS_F8YI751W1/exec";
fetch(`${scriptURL}?${query}`)
.then(response => {
if (!response.ok) throw new Error("Network response was not ok");
return response.text();
})
.then(result => {
alert("🎉 Congratulations on finishing all the rounds!\n📢 Your scores have been submitted!");
localStorage.clear(); // Optional: clear all data
})
.catch(error => {
console.error("❌ Submission failed:", error);
alert("❌ Error submitting your score. Please try again later.");
});
}
</script>
</body>
</html>