This repository has been archived by the owner on Sep 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
161 lines (143 loc) · 4.39 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<html>
<head>
<title>Time Guessing Challenge</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<style>
* {
margin: 0;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select:none;
user-select:none;-o-user-select:none;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
html {
text-align: center;
background-color: #00b187;
font-family: "Arial";
font-weight: 300;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
color: #5a5a5a;}
h1 {
color: #3e88aa;
font-weight: 300;
margin-top: 20px;
}
.container {
position: absolute;
top: 12px;
bottom: 12px;
left: 12px;
right: 12px;
padding: 20px;
background-color: #eefffb; border-radius: 40px;
}
#counter {color: black;}
a {
text-decoration: none;
color: black;
}
a.homepage {
border: 1px solid black;
border-radius: 30px;
padding: 20px 10px;
}
.retry {
padding: 10px 20px;
border: none;
background-color: #00b187;
width: 200px;
margin: 0 auto;
display:none;
border-radius: 20px;
}
.counter-container {
font-size: 40px;
height: 40px;
}
</style>
<script src="basic.js"></script>
<script src="jquery.js"></script>
<script>
function getHighScore() {
if(isCookie("timeGuesser"))
{document.getElementById("high-score").innerHTML = getCookie("timeGuesser");}
else
{setCookie("timeGuesser",0,90);}
}
$(window).on("touchstart", function(e) {
if(!$("#counter").hasClass("gameOver"))
{
clearTimeout(this.downTimer);
var counter = parseFloat($("#counter").html());
$("#lastnum").html(counter);
var attemptNumber = parseInt($("#attempt-number").html())+1;
$("#attempt-number").html(attemptNumber);
$("#counter").html(0);
$("#counter").fadeOut(4000);
$("#victory").html("Time Guesser");
$("#message").html("Try to hold down for exactly 5 seconds.");
this.downTimer = setInterval(function() {
var counter = parseFloat($("#counter").html());
counter = counter*1000;
$("#counter").html(parseFloat((counter+10)/1000).toFixed(2));
}, 10);
}
}).bind("mouseup touchend", function(e) {
if(!$("#counter").hasClass("gameOver"))
{
clearInterval(this.downTimer);
var attemptNumber = parseInt($("#attempt-number").html());
$("#counter").stop().fadeOut(10).fadeIn(10);
if($("#counter").html() == "5.00")
{
$("#counter").addClass("gameOver");
$("#victory").html("Victory!");
$("#victory").css("color","#00cb03");
$("#message").html("You won in "+attemptNumber+" attempt(s).");
$("#attempt-number").html("0");
$("#lastnum").html("0");
$(".retry").show();
$("#lastnum").parent().hide();
$("#attempt-number").parent().hide();
var highscore = getCookie("timeGuesser");
if(attemptNumber < highscore || highscore == 0)
{setCookie("timeGuesser",attemptNumber,90);
$("#high-score").html(attemptNumber);}
}
//attemptNumber++;
var counter = parseFloat($("#counter").html());
var currentError = $("#average-error").html();
var averageError = parseFloat((currentError * attemptNumber + (-1 * parseFloat((5 - counter) / 5 * 100).toFixed(2))) / attemptNumber).toFixed(2);
$("#average-error").html(averageError);
$("#attempt-number").html(attemptNumber);
}
});
</script>
</head>
<body onload="getHighScore()">
<div class="container-container">
<div class="container">
<h1 id="victory">Time Guesser</h1>
<div id="message">Try to hold down for exactly 5 seconds.</div><br/><br/>
<div class="counter-container"><span id="counter">0</span></div><br/><br/>
<div>Last Attempt: <span id="lastnum">0</span></div>
<div style="display:none;">Average Error: <span id="average-error">0</span>%</div>
<div>Total Attempts: <span id="attempt-number">0</span></div><br/><br/>
<a href=""><div class="retry">Retry</div><a/>
<br/><br/><div id="high-score-container" class="high-score-container">High Score: <br/><span id="high-score">0</span> attempt(s)</div>
<h4 style="text-align;center;font-weight:300; padding:75px;">©thisismywebsitenow.com</h4>
</div>
</div>
</body>
</html>