forked from cbiggins/beeroclock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·212 lines (170 loc) · 8.21 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
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
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Is it Beer O'Clock?</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link href='http://fonts.googleapis.com/css?family=Orienta|Ranchers' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.6.1.min.js"></script>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an outdated browser. <a href="http://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p>
<![endif]-->
<!-- Add your site or application content here -->
<div class="content">
<div class="title">Is it Beer O'Clock?</div>
<div class="rules">
<p>The rules are simple.</p>
<ul>
<li>If its a weekday, Beer O'clock is after 5pm.</li>
<li>If its a weekend, Beer O'clock is after 12pm.</li>
</ul>
</div>
<div id="togo">
</div>
<div id="beeroclock">
</div>
<div class="share">
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.8.0.min.js"><\/script>')</script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2740110-14']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script>
$(document).ready(function() {
function roundVal(val, dec){
var result = Math.round(val*Math.pow(10,dec))/Math.pow(10,dec);
return result;
}
function getMinsToGo(togo) {
val = roundVal(roundVal(togo-Math.floor(togo), 2)*60, 0);
if (val == 0) {
return false;
}
return val;
}
function getHoursToGo(togo) {
return Math.floor(togo*Math.pow(10,0))/Math.pow(10,0);
}
function updateTime() {
var d = new Date();
var day = d.getDay();
var hour = d.getHours();
var one_hour = 1000*60*60
var weekday = false;
// Is it a weekday?
if (day > 0 && day < 6) {
weekday = true;
}
var message = '';
// Clone Date and set some defaults.
var targetDate = new Date(d);
targetDate.setMinutes(00);
targetDate.setSeconds(00);
var beeroclock = false;
// If its a weekend, check its after 12.
if (!weekday) {
targetDate.setHours(12);
togo = roundVal(parseFloat((targetDate.getTime()-d.getTime())/(one_hour)), 2);
mins_togo = getMinsToGo(togo);
hours_togo = getHoursToGo(togo);
hours_msg = '';
if (hours_togo) {
hours_msg = hours_togo + ' hrs ';
if (mins_togo) {
hours_msg += 'and ';
}
}
mins_msg = '';
if (mins_togo) {
mins_msg = mins_togo + 'mins';
}
if (hour > 11) {
message = 'It is after 12 and its a weekend. Its Already Beer\ O\'Clock!';
message2 = 'YES! Its Beer\ O\'Clock!';
beeroclock = true;
}
else {
message = 'Its a weekend, but not after 12 yet. You only have ' + hours_msg + mins_msg + ' to wait.';
message2 = 'Only ' + hours_msg + mins_msg + ' until Beer\ O\'Clock!!';
}
}
else {
targetDate.setHours(17);
togo = roundVal(parseFloat((targetDate.getTime()-d.getTime())/(one_hour)), 2);
mins_togo = getMinsToGo(togo);
hours_togo = getHoursToGo(togo);
hours_msg = '';
if (hours_togo) {
hours_msg = hours_togo + ' hrs ';
if (mins_togo) {
hours_msg += 'and ';
}
}
mins_msg = '';
if (mins_togo) {
mins_msg = mins_togo + 'mins';
}
if (hour > 16) {
message = 'It is after 5PM. Its Already Beer\ O\'Clock!';
message2 = 'YES! Its Beer\ O\'Clock!';
beeroclock = true;
}
else {
message = 'Not long to go. <strong>You only have ' + hours_msg + mins_msg + ' to wait.</strong>';
message2 = 'Only ' + hours_msg + mins_msg + ' until Beer\ O\'Clock!!';
}
}
// Lets find out where it IS beer oclock
if (!beeroclock) {
$.ajax({
url: "beeroclock.php"
}).done(function ( data ) {
boc = $.parseJSON(data);
boc_html = "<span class='fret'>Don't fret! It <em>is</em> Beer O'clock in the following locations!</span><ul>";
console.log(boc);
for (i in boc) {
boc_html += '<li>' + boc[i].name + ' - ' + boc[i].time + '</li>';
}
boc_html += '</ul>';
$('#beeroclock').html();
$('#beeroclock').html(boc_html);
});
}
$('#togo').html();
$('#togo').html(message);
$('.share').empty();
$('.share').prepend('<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://christianbiggins.com/beeroclock" data-text="' +message2+ '" data-via="cbiggins" data-size="large">Tweet</a>');
$.getScript("http://platform.twitter.com/widgets.js");
$('.share').append('<a href="https://twitter.com/cbiggins" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @cbiggins</a>');
window.setInterval(updateTime, 60000);
}
updateTime();
});
</script>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</body>
</html>