-
Notifications
You must be signed in to change notification settings - Fork 1
/
typing.php
259 lines (219 loc) · 6.94 KB
/
typing.php
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
<!DOCTYPE html>
<html>
<title>W3.CSS Template</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-theme-blue-grey.css">
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Open+Sans'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style>
.text {
margin-top: 40px;
padding-bottom: 40px;
text-align: center;
}
.text h2 {
font-size: 30px;
font-style: normal;
font-variant: normal;
font-weight: lighter;
letter-spacing: 2px;
}
.counter {
-moz-box-shadow: inset 0 0 5px #000000;
-webkit-box-shadow: inset 0 0 5px #000000;
box-shadow: inset 0 0 5px #000000;
min-height: 150px;
text-align: center;
}
.counter h3 {
font-size: 24px;
font-style: normal;
font-variant: normal;
font-weight: lighter;
letter-spacing: 1px;
padding-top: 20px;
margin-bottom: 30px;
}
#countdown span {
font-size: 26px;
font-weight: normal;
margin-left: 20px;
margin-right: 20px;
text-align: center;
}
html,body,h1,h2,h3,h4,h5 {font-family: "Open Sans", sans-serif}
body{
min-height:700px;
}
#first-footer{
position:fixed;
bottom:0px;
left:0px;
right:0px;
}
#second-footer{
height:30px;
line-height:30px;
position:fixed;
bottom:60px;
left:0px;
right:0px;
}
.fa-times{
color:red;
}
.fa-check{
color:green;
}
.to-type{
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
</style>
<body class="w3-theme-l5">
<!-- Navbar -->
<div class="w3-top">
<div class="w3-bar w3-theme-d2 w3-left-align w3-large">
<a class="w3-bar-item w3-button w3-hide-medium w3-hide-large w3-right w3-padding-large w3-hover-white w3-large w3-theme-d2" href="javascript:void(0);" onclick="openNav()"><i class="fa fa-bars"></i></a>
<a href="#" class="w3-bar-item w3-button w3-padding-large w3-theme-d4"><i class="fa fa-home w3-margin-right"></i>Logo</a>
<a href="#" class="w3-bar-item w3-button w3-hide-small w3-right w3-padding-large w3-hover-white" title="My Account"><img src="/w3images/avatar2.png" class="w3-circle" style="height:25px;width:25px" alt="Avatar"></a>
</div>
</div>
<!-- Navbar on small screens -->
<div id="navDemo" class="w3-bar-block w3-theme-d2 w3-hide w3-hide-large w3-hide-medium w3-large">
<a href="#" class="w3-bar-item w3-button w3-padding-large">Link 1</a>
<a href="#" class="w3-bar-item w3-button w3-padding-large">Link 2</a>
<a href="#" class="w3-bar-item w3-button w3-padding-large">Link 3</a>
<a href="#" class="w3-bar-item w3-button w3-padding-large">My Profile</a>
</div>
<!-- Page Container -->
<div class="w3-container w3-content" style="max-width:1400px;margin-top:80px;min-height:450px;">
<!-- The Grid -->
<div class="w3-row">
<div class="w3-col m2">
<div class="w3-card-2 w3-round w3-white">
<div class="w3-container" >
</div>
</div>
</div>
<div class="w3-col m8">
<div class="w3-card-2 w3-round w3-white">
<div class="jumbotron" style="padding:20px">
<h3>Typing Test</h3>
<button id="start-test" type="button" class="btn btn-primary pull-right" style="margin-top:10px;background-color:#4d636f">Start Test</button>
<h3>Type the following paragraph</h3>
<p class="to-type">Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web.</p>
<form>
<div class="form-group">
<textarea class="form-control" rows="5" id="typed"></textarea>
<button id="submit" type="button" class="btn btn-primary" style="margin-top:10px;background-color:#4d636f">Submit</button>
</div>
</form>
<div class="counter">
<h3>Estimated Time Remaining Before Launch:</h3>
<div id="countdown">
<span class="minutes">
3<b> Minutes</b></span> <span class="seconds">0<b> Seconds</b></span>
</div><!-- /#Countdown Div -->
</div> <!-- /.Counter Div -->
<div class="speed">
</div>
</div>
</div>
</div>
<!-- End Grid -->
</div>
<!-- End Page Container -->
</div>
<br>
<!-- Footer -->
<footer class="w3-container w3-theme-d3 w3-padding-16" id="first-footer">
<h5>Copyright content</h5>
</footer>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
var interval;
$("#submit").click(function(){
clearInterval(interval);
getSpeed();
});
$("#start-test").click(function(){
// set the date we're counting down to
var target_date = new Date().getTime() + (3000 * 60);
// variables for time units
var days, hours, minutes, seconds;
// get tag element
var countdown = document.getElementById('countdown');
var count = 1;
// update the tag with id "countdown" every 1 second
interval = setInterval(function () {
count++;
// find the amount of "seconds" between now and target
var current_date = new Date().getTime();
var seconds_left = (target_date - current_date) / 1000;
minutes = parseInt(seconds_left / 60);
seconds = parseInt(seconds_left % 60);
// format countdown string + set tag value
countdown.innerHTML = '<span class="minutes">'
+ minutes + ' <b>Minutes</b></span> <span class="seconds">' + seconds + ' <b>Seconds</b></span>';
if(count == (60*3))
{
clearInterval(interval);
getSpeed();
}
if( $("#typed").val() == $(".to-type").html())
{
clearInterval(interval);
getSpeed();
}
}, 1000);
});
function getSpeed(){
var number_of_words = $("#typed").val();
var wpm = number_of_words.split(" ");
var type = $(".to-type").html();
if(type == number_of_words)
{
$(".speed").append("Your speed is "+ wpm.length);
}
else{
$(".speed").append("<p><center>There was a typo</center></p>");
}
}
</script>
<script>
// Accordion
function myFunction(id) {
var x = document.getElementById(id);
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
x.previousElementSibling.className += " w3-theme-d1";
} else {
x.className = x.className.replace("w3-show", "");
x.previousElementSibling.className =
x.previousElementSibling.className.replace(" w3-theme-d1", "");
}
}
// Used to toggle the menu on smaller screens when clicking on the menu button
function openNav() {
var x = document.getElementById("navDemo");
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
} else {
x.className = x.className.replace(" w3-show", "");
}
}
</script>
</body>
</html>