-
Notifications
You must be signed in to change notification settings - Fork 0
/
clickTheButton.html
205 lines (201 loc) · 5.3 KB
/
clickTheButton.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
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
---
title: Click The Button
description: Click it! Then click it again five seconds later!
permalink: click-the-button/
comments: true
social: true
socialImg: assets/social/click.png
featPosts: ["dogenerator","sport","converter"]
---
{% include header.html %}
<style>
/* Typography */
.column h2, .column h3, .column h4, .column h5, .column h6 {
color:#222;
}
.postHeader {
font-size:30px;
padding-top:20px;
}
/* Formatting */
body.click {
background:steelblue;
}
.post {
margin-top: 100px;
padding:50px 20px 10px;
background: #eee;
position: relative;
border-radius: 2px;
box-shadow: 0 1px 2px rgba(0,0,0,0.2);
text-align: center;
}
.postHeader {
font-size: 5em;
margin: 0 0 -5px;
line-height: 1em;
}
#clicker {
text-decoration: none;
line-height: 1em;
font-weight: normal;
}
.post h4 {
line-height: 1.3em;
font-size: 1.4em;
}
.btn {
padding: 15px 30px 10px;
font-size: 2em;
color: #fff;
background-color: steelblue;
outline: none;
}
.btn:hover, .btn:focus {
color: #fff;
background-color: #2779be;
}
#clock {
position: absolute;
width: 90px;
height: 90px;
left: 50%;
top: -45px;
margin-left: -45px;
border-radius: 100px;
background:#fff;
color: #25ae91;
text-align: center;
font-size: 6em;
line-height: 185px;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.no-csstransforms #clock {
display: none;
}
#clock::after {
position: absolute;
display: inline-block;
content: '';
top: 50%;
left: 50%;
width: 8px;
height: 8px;
background: #303239;
border-radius: 10px;
margin: -4px 0 0 -4px;
}
.clockHand {
position: absolute;
display: inline-block;
width: 0;
height: 8px;
top: 50%;
left: 50%;
}
@-webkit-keyframes webkitRotate {
from {
-webkit-transform: rotate(0deg);
} to {
-webkit-transform: rotate(360deg);
}
}
@keyframes rotate {
from {
transform: rotate(0deg);
} to {
transform: rotate(360deg);
}
}
.clockHand {
-webkit-animation-name: webkitRotate;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
animation-name: rotate;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.clockHand.hours {
margin: -4px 0 0 -20px;
border-right: 20px solid #303239;
border-left: 20px solid transparent;
-webkit-transform:rotate(-60deg);
-moz-transform:rotate(-60deg);
-ms-transform:rotate(-60deg);
-o-transform:rotate(-60deg);
transform:rotate(-60deg);
-webkit-animation-duration: 60s;
}
.clockHand.minutes {
margin: -4px 0 0 -35px;
border-right: 35px solid #303239;
border-left: 35px solid transparent;
-webkit-transform:rotate(-90deg);
-moz-transform:rotate(-90deg);
-ms-transform:rotate(-90deg);
-o-transform:rotate(-90deg);
transform:rotate(-90deg);
-webkit-animation-duration: 5s;
}
.paused{
-webkit-animation-play-state:paused;
-moz-animation-play-state:paused;
-o-animation-play-state:paused;
animation-play-state:paused;
}
#result {
font-size: 2.3em;
line-height: 1em;
margin: 1em 0;
}
.meta {
color: #fff;
opacity: 0.9;
}
</style>
</head>
<body class="grey click">
{% include nav.html %}
<main class="wrapper">
<article class="post">
<h2 class="postHeader">{{ page.title }}</h2>
<span id="clock">
<span class="clockHand minutes" data-0="transform:rotate(0deg);" data-end="transform:rotate(10800deg);"></span>
<span class="clockHand hours" data-0="transform:rotate(0deg);" data-end="transform:rotate(900deg);"></span>
</span>
<h4>Wait five seconds then click it again.</h4>
<p><a id="clicker" class="btn" tabindex="1">Click me!</a></p>
<h5 id="result"></h5>
<p>The aim of the game is to get as close to five seconds as you can.<br/> This page was originally built as a test prototype for Apigee data storage, and it used to have a histogram graph below showing user times but the data-connection has expired.</p>
</article>
<p class="meta">Published 2 July 2013</p>
</main>
{% include footerJS.html %}
<script>
$(function(){
// Define some global variables:
var timeStamp = {
start: 0,
stop: 0,
duration: 0
};
// Make things happen when you click the button:
$('#clicker').on('click',function(e){
e.preventDefault;
if(!$(this).hasClass('timerRunning')) {
// Timer isn't running so run it
timeStamp.start = new Date().getTime();
$(this).text("Stop timer").addClass('timerRunning btn-danger');
$('.clockHand').addClass('paused');
} else {
// Stop the timer and do stuff
timeStamp.stop = new Date().getTime();
timeStamp.duration = parseFloat((timeStamp.stop - timeStamp.start)/1000);
$(this).text("Start timer").removeClass('timerRunning btn-danger');
$('#result').html(timeStamp.duration.toFixed(3)+" seconds.").slideDown();
$('.clockHand').removeClass('paused');
}
});
});
</script>
{% include footer.html %}