-
Notifications
You must be signed in to change notification settings - Fork 26
/
index.html
88 lines (86 loc) · 4.03 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
<!DOCTYPE html>
<!-- http://dev.w3.org/html5/html-xhtml-author-guide/ -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" manifest="cache.manifest">
<head>
<title>Moon Phase</title>
<style>
.moon { fill:#D6D5C0; }
.moonback { fill:black;stroke:#fff;stroke-width:1px; }
body {
background-color:black;
background-image: url('background.jpg');
overflow: hidden;
}
/* #moon { margin-top: 3em; } */
</style>
<meta charset="utf-8" />
<!-- http://matt.might.net/articles/how-to-native-iphone-ipad-apps-in-javascript/ -->
<!-- meta name="apple-mobile-web-app-capable" content="yes" / -->
<!-- meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" / -->
<meta name="viewport" content="width=device-width" / >
</head>
<body>
<svg id="moon" style="position:absolute; left:10%; top:10%;" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" version="1.1"/>
<div id="riseset" style="position: absolute; bottom:0; left:0; background: white; visibility:hidden; ">
<table>
<tr><td><span title="moonrise" id="moonrise"/></td><td title="moonrise">☽</td>
<td><span title="moonset" id="moonset"/></td><td title="moonset">☾</td></tr>
<tr><td><span title="sunrise" id="sunrise"/></td><td title="sunrise">☼</td>
<td><span title="sunset" id="sunset"></td><td title="sunset">☀</td></tr>
<tr><td colspan="2"><span style="font-size: small;" id="date"/></td><td><span id="mooncent"/></td><td><span id="zodiac"></td></tr>
</table>
</div>
<a href="https://github.com/tingletech/moon-phase"
style="position: absolute; top: 0; right: 0; border: 0;" >
<img src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png"
alt="Fork me on GitHub" >
</a>
</body>
<script type="text/javascript" src="moon-phase.js" charset="UTF-8"></script>
<script type="text/javascript" src="riset.js" charset="UTF-8"></script>
<script type="text/javascript" src="zodiac.js" charset="UTF-8"></script>
<script type="text/javascript" charset="UTF-8">
// this only get run if we can get a location ... should have a fallback if they don't have location.?
var success = function(position) {
var lon = position.coords.longitude;
var lat = position.coords.latitude;
var today = today || new Date();
var year = today.getFullYear();
var day = today.getDate();
var month = today.getMonth()+1; // 0 index :(
var hours = today.getHours();
var tz = -today.getTimezoneOffset()/60;
var mj = mjd(day, month, year, 0.0);
var riset = find_moonrise_set(mj, tz, lon, lat);
var moonrise = riset[0];
var moonset = riset[1];
document.getElementById('moonrise').innerHTML += moonrise;
document.getElementById('moonset').innerHTML += moonset;
document.getElementById('riseset').style.visibility = 'visible';
var sunrs = find_sun_and_twi_events_for_date(mj, tz, lon, lat).split(" ");
var sunrise = sunrs[1];
var sunset = sunrs[2];
document.getElementById('sunrise').innerHTML += sunrise;
document.getElementById('sunset').innerHTML += sunset;
document.getElementById('date').innerHTML += year + "/" + month + "/" + day;
document.getElementById('zodiac').innerHTML += zodiac_sign(today);
document.getElementById('mooncent').innerHTML += (moon_day(today)*100).toFixed(2) + "%";
};
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success);
}
// http://tutorialzine.com/2010/03/centering-div-vertically-and-horizontally/
function center(){
moonelement=document.getElementById('moon')
moonelement.style.position='absolute';
moonelement.style.left=((document.body.clientWidth - moonelement.offsetWidth)/2);
moonelement.style.top=((window.innerHeight - moonelement.offsetHeight)/2);
console.log(document.body.clientWidth);
console.log(Math.max( window.innerHeight, document.body.clientHeight ));
}
window.onresize = function(){
center();
};
center();
</script>
</html>