-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrapdoor.html
148 lines (114 loc) · 4.34 KB
/
trapdoor.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
<!-- CODE FOR FORM VALIDATION:
https://www.w3schools.com/js/js_validation.asp
CODE FOR LOADING DIV AT CERTAIN TIME
https://www.w3schools.com/jsref/event_onload.asp
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title> trap door</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta charset="utf-8">
<link href = "http://webdev.scs.ryerson.ca/~j29long/project/traproom.css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Xanh+Mono&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Nosifer&display=swap" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<!--JAVASCRIPT TO VALDIATE FORM-->
<script type ="text/javascript">
function validateForm()
{
var x = document.forms["myForm"]["answer"].value; //get answer value from form
//if the answers are any of these
if (x == "59 59" || x == "59 min 59 sec"||x== "5959" ||x =="59 minute 59 seconds")
{
return true;
} //if answers are not those above, make an alert
alert ("Incorrect answer");
return false;
}
</script>
</head>
<body>
<!--MUSIC-->
<audio autoplay loop>
<source src="battleMusic.mp3">
</audio>
<!--ALERT BOX ON TOP OF TEH PAGE-->
<div class="alert">
<span class="closebtn" onclick="this.parentElement.style.display='none';">×</span>
You're <em>TRAPPED ! </em>Answer this question to escape!
</div>
<!--TIMER-->
<div id="timer"> </div>
<div id="wrapper">
<!--RIDDLE-->
<div class="riddle">
<p>Once put in an petri dish, the corona virus starts duplicating, each <strong>second</strong> the virus <strong>doubles</strong> himself,
<br> Which mean after 1 second there will be 2 viruses, then 4, then 8 and so on...
<br>After <strong>one hour</strong> the petri dish was <em>perfectly full</em>.
<br>When was the plate exactly <strong>half full</strong>?</p>
</div>
<!--FORM FOR ACCEPTING VALUE-->
<div class="answerBox">
<!--REDIRECTS TO THIS PAGE IF ANSWER IS CORRECT-->
<form name="myForm" action ="http://webdev.scs.ryerson.ca/~hhvu/page11.html" onsubmit="return validateForm()" method="post"> <!-- CHANGE PAGE DESTINATION-->
<input type="text" name="answer" id="answer" placeholder="answer"> <br/>
<div class="submitBox">
<input class="button" type="submit" value="submit">
</div>
</form>
</div>
<!--BACK BUTTON-->
<div id ="back" class="backButton">
<a href="http://webdev.scs.ryerson.ca/~j29long/project/page10.html" class="button">Go back!</a>
<!--JAVASCRIPT TO DISPLAY BACK BUTTON AT A CERTAIN TIME-->
<script>
const back = document.getElementById('back');
back.style.display = 'none';
setTimeout(()=> {back.style.display= 'block';},50000); // change the timing for longer -50000 = 5 min
</script>
</div>
</div>
<!--TIMER-->
<script type="text/javascript">
var timePassed = parseInt(sessionStorage.getItem('timePassed'));
let timerInterval = null;
document.getElementById("timer").innerHTML = `
<div class="base-timer">
<svg class="base-timer__svg" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<g class="base-timer__circle">
<circle class="base-timer__path-elapsed" cx="50" cy="50" r="45"></circle>
</g>
</svg>
<span id="base-timer-label" class="base-timer__label">${formatTime(
timePassed
)}</span>
</div>`;
startTimer();
function startTimer() {
timerInterval = setInterval(() => {
timePassed += 1;
document.getElementById("base-timer-label").innerHTML = formatTime(
timePassed
);
}, 1000);
}
function formatTime(time) {
const minutes = Math.floor(time / 60);
let seconds = time % 60;
if (seconds < 10) {
seconds = `0${seconds}`;
}
return `${minutes}:${seconds}`;
}
//AFTER EACH PAGE, BEFORE LINE DIRECTING TO NEXT INPUT
function redirect()
{
sessionStorage.setItem("timePassed", timePassed);
window.location.href="http://webdev.scs.ryerson.ca/~hhvu/page11.html";
}
</script>
</body>
</html>