|
| 1 | + |
| 2 | +<!----------------------------------------------------- |
| 3 | +sleepyti.me bedtime calculator |
| 4 | +Author: David Shaw (dshaw dot jobs at gmail dot com) |
| 5 | +URL: http://github.com/davidshaw/sleepyti.me/ |
| 6 | +------------------------------------------------------> |
| 7 | + |
1 | 8 | <html>
|
2 | 9 | <head>
|
3 | 10 | <title>sleepyti.me bedtime calculator</title>
|
| 11 | +<META NAME="Description" CONTENT="Sleepyti.me is a bedtime calculator that can help you calculate when to fall asleep. By counting backwards in sleep cycles, sleepyti.me has the ability to help you wake up refreshed, instead of feeling groggy. Sleepyti.me can also help you figure out what time to set your alarm if you are going to sleep at that moment."> |
| 12 | +<META NAME="Keywords" CONTENT="sleep, refreshed, sleeping, health, bedtime, bed, bed time, calculator, ajax, javascript"> |
| 13 | +<META NAME="robots" CONTENT="index"> |
4 | 14 | <script src="jquery.js"></script>
|
5 | 15 | <script>
|
6 | 16 | $(document).ready(function() {
|
7 | 17 | function ren() {
|
8 | 18 | // render the page -- in case you're wondering,
|
9 | 19 | // nothing will work without javascript!
|
10 |
| - $("#tit").html('<font face="Garamond"><h1> <i>sleepyti.me <font color="#33CC33">beta 2</font></i></h1></font>'); |
| 20 | + $("#tit").html('<font face="Garamond"><h1> <i>sleepyti.me <font color="#33CC33">beta 3</font></i></h1></font>'); |
11 | 21 | var mrend = '';
|
12 | 22 | mrend = mrend +
|
13 | 23 | '<table><tr width="100%">' +
|
|
41 | 51 | '<td></td></span>' +
|
42 | 52 | '<td></tr><tr><span class="results" style="display:none;"></span></td>' +
|
43 | 53 | '</tr></table>';
|
44 |
| - |
45 | 54 | $('#main').html(mrend);
|
46 | 55 | }
|
47 | 56 | ren();
|
48 | 57 |
|
| 58 | + function putads() { |
| 59 | + // let's throw in some ads |
| 60 | + $('#amazon').fadeIn(2500); |
| 61 | + } |
| 62 | + |
49 | 63 | // calculates an hour and a half back
|
50 | 64 | function sleepback(hr, min, an) {
|
51 | 65 | var rmin = 0;
|
|
101 | 115 | }
|
102 | 116 | }
|
103 | 117 |
|
104 |
| - r = '<p>It takes the average human <b>fourteen minutes</b> to fall asleep.</p><p>If you head to bed right now, you should try to wake up at one of the following times:</p><p> <font size=6><font color="#666666">'; |
105 |
| - for(var ctr = 0; ctr < 6; ctr++) { // normal sleep scheedule |
| 118 | + r = '<table><tr><td width="5%"></td><td><font size="5"><p>It takes the average human <b>fourteen minutes</b> to fall asleep.</p><p>If you head to bed right now, you should try to wake up at one of the following times:</p><h2><font color="#666666">'; |
| 119 | + for(var ctr = 0; ctr < 6; ctr++) { // normal sleep schedule |
106 | 120 | // add an hour and a half
|
107 | 121 | if(min < 30) {
|
108 | 122 | min = min + 30;
|
|
131 | 145 | ap = ' PM';
|
132 | 146 | dhr = hr - 12;
|
133 | 147 | }
|
| 148 | + if(dhr == 0) { |
| 149 | + dhr = 12; |
| 150 | + } |
134 | 151 | if(ctr == 0) {
|
135 | 152 | if(min > 9) {
|
136 | 153 | r = r + dhr + ':' + min + ap;
|
|
157 | 174 | }
|
158 | 175 | else {
|
159 | 176 | if(min > 9) {
|
160 |
| - r = r + ' <i>or</i> ' + hr + ':' + min + ap; |
| 177 | + r = r + ' <i>or</i> ' + dhr + ':' + min + ap; |
161 | 178 | }
|
162 | 179 | else {
|
163 |
| - r = r + ' <i>or</i> ' + hr + ':0' + min + ap; |
| 180 | + r = r + ' <i>or</i> ' + dhr + ':0' + min + ap; |
164 | 181 | }
|
165 | 182 | }
|
166 | 183 | }
|
167 |
| - r = r + '</font></font></p><p>A good night\'s sleep consists of 5-6 complete sleep cycles.</p>'; |
168 |
| - r = r + '<a href="index.html">back</a>'; |
| 184 | + r = r + '</h2></font><p>A good night\'s sleep consists of 5-6 complete sleep cycles.</p>'; |
| 185 | + r = r + '<center><a href="index.html"><h3>back</h3></a></center>'; |
169 | 186 | return r;
|
170 | 187 | }
|
171 | 188 |
|
|
179 | 196 | var d = new Date();
|
180 | 197 | answ = knockout(d); // knockout takes a Date() and returns a string of wake times
|
181 | 198 | st = '<span id="bit" style=display:none><font face="Garamond" size=5>' +
|
182 |
| - answ + |
183 |
| - '</font></span>'; |
184 |
| - $('#main').fadeOut(500); |
| 199 | + answ + '</font></span>'; |
| 200 | + $('#main').hide(); |
185 | 201 | $('#instant').html(st);
|
186 |
| - $('#bit').delay(500).show(500); |
| 202 | + $('#instant').show() |
| 203 | + $('#bit').show(250); |
| 204 | + putads() |
187 | 205 | });
|
188 | 206 |
|
189 | 207 | // user changes the list, so we calculate times!
|
|
207 | 225 | }
|
208 | 226 | }
|
209 | 227 |
|
210 |
| - var txt = '<font face="Garamond" size=5><br/><br/>You should try to <b>fall asleep</b> at one of the following times:<br/><br/><font size=6>'; |
| 228 | + var txt = '<table><tr><td width="5%"></td><td><font face="Garamond" size=5>You should try to <b>fall asleep</b> at one of the following times:<br/><br/><font size=6>'; |
211 | 229 | var first = true;
|
212 |
| - |
| 230 | + var times = new Array(); |
213 | 231 | for(var c = 1; c <= 10; c++) {
|
214 | 232 | var back = sleepback(hr, min, ampm);
|
215 | 233 | var nhr = back[0];
|
216 | 234 | var nmin = back[1];
|
217 | 235 | ampm = back[2];
|
218 | 236 | var ampmt = "";
|
219 | 237 | ampmt = back[2];
|
| 238 | + |
220 | 239 | // countdown from 12, but that's not
|
221 | 240 | // how am/pm system works... whoops!
|
222 | 241 | if(nhr == 12) {
|
|
227 | 246 | ampmt = "AM";
|
228 | 247 | }
|
229 | 248 | }
|
230 |
| - |
| 249 | + // TODO: reverse display order |
231 | 250 | if(c == 6 || c == 4 || c == 5 || c == 3) {
|
| 251 | + var temp = ''; |
232 | 252 | if(nmin > 9) {
|
233 |
| - if(first == true) { |
234 |
| - first = false; |
235 |
| - txt = txt + '<font color="#01DF74" size="7">' + nhr + ':' + nmin + ' ' + ampmt + '</font>'; |
| 253 | + if(c == 6) { |
| 254 | + temp = '<font color="#01DF74" size="7">' + nhr + ':' + nmin + ' ' + ampmt + '</font>'; |
| 255 | + times.push(temp); |
236 | 256 | }
|
237 | 257 | else {
|
238 |
| - txt = txt + ' <i>or</i> ' + '<font color="#01DF74" size="7">' + nhr + ':' + nmin + ' ' + ampmt + '</font>'; |
| 258 | + temp = ' <i>or</i> ' + '<font color="#01DF74" size="7">' + nhr + ':' + nmin + ' ' + ampmt + '</font>'; |
| 259 | + times.push(temp); |
239 | 260 | }
|
240 | 261 | }
|
241 |
| - else { |
242 |
| - if(first == true) { |
243 |
| - first = false; |
244 |
| - txt = txt + '<font color="#01DF74" size="7">' + nhr + ':0' + nmin + ' ' + ampmt + '</font>'; |
245 |
| - } |
246 |
| - else { |
247 |
| - txt = txt + ' <i>or</i> ' + '<font color="#01DF74" size="7">' + nhr + ':0' + nmin + ' ' + ampmt + '</font>'; |
248 |
| - } |
| 262 | + else { // insert 0 |
| 263 | + if(c == 6) { |
| 264 | + temp = '<font color="#01DF74" size="7">' + nhr + ':0' + nmin + ' ' + ampmt + '</font>'; |
| 265 | + times.push(temp); |
| 266 | + } |
| 267 | + else { |
| 268 | + temp = ' <i>or</i> ' + '<font color="#01DF74" size="7">' + nhr + ':0' + nmin + ' ' + ampmt + '</font>'; |
| 269 | + times.push(temp); |
| 270 | + } |
| 271 | + |
249 | 272 | }
|
250 | 273 | }
|
251 | 274 | hr = nhr;
|
252 | 275 | min = nmin;
|
253 | 276 | }
|
| 277 | + for(i = 3; i >= 0; i--) { |
| 278 | + txt = txt + times[i]; |
| 279 | + } |
| 280 | + |
254 | 281 | txt = txt + '</font>';
|
255 | 282 |
|
256 | 283 | txt = txt + '<br/><br/><font color="#0080FF">Please keep in mind that you should be <i>falling asleep</i> at these times.<br/><br/> The average adult human takes <b>fourteen minutes</b> to fall asleep, so plan accordingly!</font>';
|
257 | 284 | txt = txt + '<br/></br><font color="#9966CC">sleepyti.me works by counting backwards in <b>sleep cycles</b>. Sleep cycles typically last <b>90 minutes</b>.<br/><br/>Waking up in the middle of a sleep cycle leaves you feeling tired and groggy, but waking up <i>in between</i> cycles lets you wake up feeling refreshed and alert!</font>';
|
258 |
| - txt = txt + '<br/><br/><a href="index.html"><big>back</big></a>'; |
259 |
| - txt = txt + '<br/><br/><br/><span class="donate" style="display:none;"></span>'; |
260 |
| - $('#main').fadeOut(1000); |
261 |
| - $('#instant').delay(1000).html(txt); |
262 |
| - $('#instant').delay(1000).fadeIn(1000); |
| 285 | + txt = txt + '<br/><br/><center><a href="index.html"><h3>back</h3></a></center>'; |
| 286 | + $('#main').hide(); |
| 287 | + $('#instant').html(txt) |
| 288 | + $('#instant').show(500) |
263 | 289 |
|
264 |
| - donate = '<font face="Garamond" size=5 color="#666666"><table><tr height="100%"><td valign="bottom">Are you waking up refreshed because of sleepyti.me? Consider donating to support this free and open source project!<br/><br/>' + |
265 |
| - '<center>' + |
266 |
| - '<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick">' + |
267 |
| - '<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHRwYJKoZIhvcNAQcEoIIHODCCBzQCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBpCHT8Af6SL2MQnFqUr4y2BGrDArDDX0GSvt5t/Wu+DBiWgQj6u5HludfZn6tdMVFOJ0joDwm6W92y7DK5QQo54fGAEo6LGSL88Q8eNgjksP98M1NXyutWNT9vu0SC0br3k1TQS/S7VczbiW7y5nleo7Qtb8H2fuqe5uPdfhcKuTELMAkGBSsOAwIaBQAwgcQGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIm1dWir2jBi+AgaBN/scqXKEUoQ5O19mUesLossK/VHQ4C9RHt8KcMcw8VkNK6BNvdVGYMjm+RHVqHOsPjW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ZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCBXzpWmoBa5e9fo6ujionW1hUhPkOBakTr3YCDjbYfvJEiv/2P+IobhOGJr85+XHhN0v4gUkEDI8r2/rNk1m0GA8HKddvTjyGw/XqXa+LSTlDYkqI8OwR8GEYj4efEtcRpRYBxV8KxAW93YDWzFGvruKnnLbDAF6VR5w/cCMn5hzGCAZowggGWAgEBMIGUMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTAxMDA0MDMwNTQzWjAjBgkqhkiG9w0BCQQxFgQU1GjaUiJxCQZO4a5l5+VUwbCIfogwDQYJKoZIhvcNAQEBBQAEgYCYtrrshPFV96iF/OhEW5Ir+Ur+Eb1BrBjd1ASfQ4ikl5RHfRJy6UUoKoSwsCW652QzcZKsjrIDy/xYim7ESg2RNbOtNTfVrdDqlgNVKrwClV0oJx/Pt/X17NSbZq/3phsLtj8tixNsHyPTrW0+tJtlzMAxUsIlKXClkKImyEqeLQ==-----END PKCS7-----">' + |
268 |
| - '<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">' + |
269 |
| - '<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"></form>'; |
270 |
| - donate = donate + '<br/><br/><center><font face="Garamond"><h2>© <a href="http://github.com/davidshaw/dshaw_resume/raw/master/dshaw_resume_2010.pdf">David Shaw</a>, 2010</font></h2></center>'; |
271 |
| - $('.donate').html(donate); |
272 |
| - $('.donate').fadeIn(1000); // necessary? |
273 | 290 | var wtime = "";
|
274 | 291 | if(orig[1] > 9) {
|
275 | 292 | wtime = '<b>' + orig[0] + ':' + orig[1] + ' ' + orig[2] + '</b>';
|
|
279 | 296 | }
|
280 | 297 | $('.waketime').html(wtime);
|
281 | 298 | $('.waketime').fadeIn(1000);
|
| 299 | + putads(); |
282 | 300 | });
|
283 | 301 | });
|
284 | 302 | </script>
|
| 303 | + |
| 304 | +<script type="text/javascript"> |
| 305 | + |
| 306 | + var _gaq = _gaq || []; |
| 307 | + _gaq.push(['_setAccount', 'UA-19580945-1']); |
| 308 | + _gaq.push(['_trackPageview']); |
| 309 | + |
| 310 | + (function() { |
| 311 | + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
| 312 | + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
| 313 | + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
| 314 | + })(); |
| 315 | + |
| 316 | +</script> |
| 317 | + |
285 | 318 | </head>
|
286 |
| -<body> |
| 319 | +<body link="#0080FF" vlink="#0080FF"> |
| 320 | +<noscript><font face="Garamond" size="5"><center>Hello, and welcome to sleepyti.me. Sleepyti.me is a bedtime calculator that counts backwards in sleep cycles and tells you when to go to sleep so that you can wake up refreshed! This site is written in Javascript, which must be enabled in order to use the page. Thanks for visiting, and sorry for the inconvenience!</noscript> |
287 | 321 | <div id="tit"></div>
|
288 | 322 | <div id="main"></div>
|
289 |
| -<div id="instant"></div> |
| 323 | +<div id="instant" style="display:none;"></div> |
| 324 | +<div id="amazon" style="display:none;" align="center" valign="bottom"> |
| 325 | +<hr color="#CCCCCC" width="30%"><font face="Garamond" size=5 color="#666666"><i>Sleepyti.me is provided as a free service thanks to support from our ads.<br/><br/> |
| 326 | + |
| 327 | +<script type="text/javascript"><!-- |
| 328 | +google_ad_client = "ca-pub-7082199327067068"; |
| 329 | +/* sleepy */ |
| 330 | +google_ad_slot = "4113086282"; |
| 331 | +google_ad_width = 728; |
| 332 | +google_ad_height = 90; |
| 333 | +//--> |
| 334 | +</script> |
| 335 | +<script type="text/javascript" |
| 336 | +src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> |
| 337 | +</script> |
| 338 | +</div> |
| 339 | +<div id="fb"> |
| 340 | +<hr color="white"> |
| 341 | +<hr color="white"> |
| 342 | +<hr color="white"> |
| 343 | +<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fsleepyti.me&layout=standard&show_faces=true&width=450&action=like&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe> |
| 344 | +</div> |
290 | 345 | </body>
|
291 | 346 | </html>
|
0 commit comments