-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplanetrise.js
99 lines (92 loc) · 3.78 KB
/
planetrise.js
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
// Helper functions from http://cosinekitty.com/solar_system.html
var BriefDayOfWeek = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
function BriefTimeString (date)
{
if (date == null) {
return "";
} else {
var h = date.getHours();
h = ((h < 10) ? "0" : "") + h.toString();
var m = date.getMinutes();
m = ((m < 10) ? "0" : "") + m.toString();
var s = date.getSeconds();
s = ((s < 10) ? "0" : "") + s.toString();
return BriefDayOfWeek[date.getDay()] + " " + h + ":" + m + ":" + s;
}
}
function BriefDayValueString (day)
{
if (day == null) {
return "";
} else {
return BriefTimeString (Astronomy.DayValueToDate (day));
}
}
Module.register("planetrise", {
defaults: {
latitude: 34.2,
longitude: -118.1,
//bodies: ['Sun', 'Moon', 'Mercury', 'Venus', 'Mars', 'Jupiter', 'Saturn']
bodies: {'Sun': '☉',
'Moon': '☽',
'Mercury': '☿',
'Venus': '♀',
'Mars': '♂',
'Jupiter': '♃',
'Saturn': '♄',
}
},
// Define start sequence.
start: function() {
Log.info("Starting module: " + this.name);
// Schedule update interval.
var self = this;
setInterval(function() {
self.updateDom();
}, 1000*60);
},
// Override dom generator.
getDom: function() {
latitude = this.config.latitude;
longitude = this.config.longitude;
var wrapper = document.createElement("table");
wrapper.className = "small";
var AstroDateTime = new Date();
var day = Astronomy.DayValue (AstroDateTime);
var location = new GeographicCoordinates(longitude, latitude, 0);
for (var i in Astronomy.Body) {
//AddRowForCelestialBody (Astronomy.Body[i], day);
if (Object.keys(this.config.bodies).indexOf(Astronomy.Body[i].Name) >= 0){
var planetWrapper = document.createElement("tr");
planetWrapper.className = "normal";
var symbolWrapper = document.createElement("td");
symbolWrapper.className = "symbol";
//If fontio ever supports the full set
//var symbol = document.createElement("span");
//symbol.className = "fa fa-" + this.config.bodies[Astronomy.Body[i].Name];
//symbolWrapper.appendChild(symbol);
symbolWrapper.innerHTML = '<center>' + this.config.bodies[Astronomy.Body[i].Name] + '</center>';
planetWrapper.appendChild(symbolWrapper);
var titleWrapper = document.createElement("td");
titleWrapper.innerHTML = Astronomy.Body[i].Name;
titleWrapper.className = "title bright";
planetWrapper.appendChild(titleWrapper);
var riseWrapper = document.createElement("td");
riseWrapper.className = "time light";
riseWrapper.innerHTML = BriefDayValueString(Astronomy.NextRiseTime(Astronomy.Body[i], day, location));
planetWrapper.appendChild(riseWrapper);
var setWrapper = document.createElement("td");
setWrapper.className = "time light";
setWrapper.innerHTML = BriefDayValueString(Astronomy.NextSetTime(Astronomy.Body[i], day, location));
planetWrapper.appendChild(setWrapper);
//planetWrapper.innerHTML = Object.keys(Astronomy.Body[i]).toString();
wrapper.appendChild(planetWrapper);
}
}
//wrapper.innerHTML = make_text(sun_elevation, next, julian_date);
return wrapper;
},
getScripts: function() {
return['astronomy.js']
}
});