-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
97 lines (90 loc) · 2.94 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Book Sprite Sheet</title>
<style>
body, html {
height: 100%;
margin: 0;
}
#book {
background-image: url('booked.png');
width: 510px; /* Adjust as needed */
height: 540px; /* Adjust as needed */
perspective: 1000px;
margin: 50px auto;
position: relative;
}
.page {
width: 100%;
height: 100%;
position: absolute;
transform-style: preserve-3d;
transition: transform 1s;
}
.page .content {
width: 100%;
height: 100%;
padding: 20px;
box-sizing: border-box;
backface-visibility: hidden;
color: white;
font-size: 20px;
font-weight: bold;
padding-top: 40px; /* Adjust as needed */
}
.page .content input[type="text"] {
width: 35%;
margin-top: 300px;
margin-left: 240px;
padding: 5px;
font-size: 16px;
}
</style>
</head>
<body>
<div id="book" class="book">
<!-- Page with a question and an input field -->
<div class="page" style="transform: translateX(0%);">
<div class="content">
<br>
<input type="text" class="answer" placeholder="Your answer...">
</div>
</div>
</div>
<script>
// Array to store answers
const answers = [];
// Get the input field
const answerInput = document.querySelector('.answer');
// Initialize attempt counter
let attemptCount = 0;
const totalQuestions = 3; // Total number of questions, for testing purpose
// Add event listener to handle Enter key press
answerInput.addEventListener('keydown', function(event) {
if (event.key === 'Enter') {
const answer = event.target.value;
console.log('Answer:', answer);
// Store the answer
answers.push(answer);
// Save the answers to cookies
document.cookie = `answers=${JSON.stringify(answers)}; path=/`;
// Clear the input field
event.target.value = '';
// Increment attempt count
attemptCount++;
// Hide the input field after answering all questions
if (attemptCount >= totalQuestions) {
event.target.style.display = 'none';
// Close the tab after 10 seconds
setTimeout(() => {
window.close();
}, 10000);
}
}
});
</script>
</body>
</html>