-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
214 lines (192 loc) · 5.61 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
213
214
<!DOCTYPE html><!--milestone 2 - debug-->
<html>
<head>
<title>SBHS Countdown</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link href='http://fonts.googleapis.com/css?family=Roboto:100,300' rel='stylesheet' type='text/css'>
<style type="text/css">
.centered {
text-align: center;
position: absolute;
left: 0px;
width: 100%;
top: 5%;
overflow: visible;
display: block;
/*top: 50%;
left: 50%;
height: 300px;
width: 700px;
margin-top: -200px;
margin-left: -400px;*/
}
.align {
text-align: center;
position: absolute;
left: 0px;
width: 100%;
overflow: visible;
display: block;
}
#description {
font-family: 'Roboto', sans-serif;
font-weight: 300;
font-size: 50px;
color: #D6D6D6;
height: 80px;
line-height:50px;
padding-top:5px;
padding-bottom:0px;
}
#in {
font-family: 'Roboto', sans-serif;
font-style: normal;
font-weight: 100;
font-size: 25px;
color: #D6D6D6;
line-height:0px;
padding-top:0px;
padding-bottom:10px;
}
#counter {
font-family: 'Roboto', sans-serif;
font-size: 120px;
font-weight: 100;
color: #D6D6D6;
line-height: 1.1em;
}
#debug {
font-family: "Roboto", sans-serif;
font-weight: 100;
font-size: 12px;
color: #D6D6D6;
}
#faq{
position: fixed;
bottom: 7px;
left: 10px;
font-family: "Roboto", sans-serif;
text-align: left;
font-weight: 100;
font-size: 18px;
color: #d7d7d7;
z-index: 10;
}
#bottom {
position: fixed;
bottom: 7px;
font-family: "Roboto", sans-serif;
text-align: center;
font-weight: 100;
font-size: 15px;
}
#copyright{
position: fixed;
bottom: 10px;
right: 10px;
font-family: "Roboto", sans-serif;
text-align: right;
font-weight: 100;
font-size: 12px;
color: #d7d7d7;
}
</style>
<script>
var day;
var todayHours;
var todayMinutes;
var todayDesc;
var nextDay = false;
setInterval(function doCount(){
var t1Hours = [9,9,10,11,11,11,12,13,14,15];
var t1Minutes = [0,5,5,10,30,50,50,55,15,15];
var t1Desc = ["School Starts","Period 1","Period 2","Lunch","Lunch 2","Period 3","Period 4","Recess","Period 5","End of Day"];
var t2Hours = [9,9,10,11,11,12,12,13,14,15];
var t2Minutes = [0,5,5,10,30,30,50,10,10,15];
var t2Desc = ["School Starts","Period 1","Period 2","Recess","Period 3","Lunch","Lunch 2","Period 4","Period 5","End of Day"];
var t3Hours = [9,9,10,11,11,12,13,14,14,15];
var t3Minutes = [25,30,25,25,45,5,0,0,20,15];
var t3Desc = ["School Starts","Period 1","Period 2","Lunch","Lunch 2","Period 3","Period 4","Recess","Period 5","Weekends"];
var now = new Date();
day = now.getDay();
var nowHours = now.getHours();
var nowMinutes = now.getMinutes();
var nowSeconds = now.getSeconds();
//weekday overnight correction
if ((nowHours*60 + nowMinutes)>=915 && day!=6){
day += 1;
nextDay = true;
}
//grab timetables
switch (day){
case 3: //wed
case 4:
todayHours = t2Hours.slice(0);
todayMinutes = t2Minutes.slice(0);
todayDesc = t2Desc.slice(0);
break;
case 5: //fri
todayHours = t3Hours.slice(0);
todayMinutes = t3Minutes.slice(0);
todayDesc = t3Desc.slice(0);
break;
default:
todayHours = t1Hours.slice(0);
todayMinutes = t1Minutes.slice(0);
todayDesc = t1Desc.slice(0);
break;
}
var i = 0;
if (nextDay==true){
todayHours[i] += 24;
}
//weekend correction
if (day==6){
todayHours[i] += 48;
}else if (day==0){
todayHours[i] += 24
}
//next period
var nowAbsolute = nowHours*60 + nowMinutes;
while ((todayHours[i]*60 + todayMinutes[i] - 1) < nowAbsolute && nowAbsolute < 915){i++}
if (i==10){i=0}
//put last
var rHours = (todayHours[i]-nowHours);
var rMinutes = (todayMinutes[i]-nowMinutes-1);
var rSeconds = (60-nowSeconds);
if (rSeconds == 60){
rMinutes += 1;
rSeconds = 0;
}
//negative correction
if (todayMinutes[i]-1 < nowMinutes){
rHours -= 1;
rMinutes += 60;
}
//display
document.getElementById("description").innerHTML= todayDesc[i];
if (rHours!=0){
document.getElementById("counter").innerHTML= "<b>"+rHours+"</b>h, <b>"+ zeroPad(rMinutes) +"</b>m, <b>"+zeroPad(rSeconds)+"</b>s.";
}
else{
document.getElementById("counter").innerHTML= "<b>"+zeroPad(rMinutes)+"</b>m, <b>"+zeroPad(rSeconds)+"</b>s.";
}
}, 500);
function zeroPad(num) {
var s = "000" + num;
return s.substr(s.length-2);
}
</script>
</head>
<body bgcolor="#000000">
<div id="container" class="centered" >
<div id="description"></div>
<div id="in">in</div>
<div id="counter"></div>
</div>
<div id="faq"><a href="faq.html" style="color: #00aced"><img src="i.png" height=15px hspace=3px>FAQ</a></div>
<div id="bottom" class="align"><a href="https://docs.google.com/forms/d/1J-FFPzJkBjCOY4U73xIIe_UwwMqMevmX6T9FZKLmQA0/viewform" target="_blank" style="color: #00aced">Give Feedback</a></div>
<div id="copyright">© Jerry Yip 2013<br>Ported by Kenny Liu</div>
<br><br>
</body>
</html>