Skip to content

Commit 0606e8c

Browse files
added daylight cycle button
1 parent a7268ea commit 0606e8c

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<ol class="nav">
1919
<li class="home"><i class="icon-habhub"></i></li>
2020
<li class="chasecar" style="display: none"><i class="icon-car"></i></li>
21+
<li class="daylight"><i class="icon-daylight"></i></li>
2122
<li class="about last"><i class="icon-question"></i></li>
2223
</ol>
2324
<span id="locate-me" style="display: none"><i class="icon-target"></i></span>

js/app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ $(window).ready(function() {
201201
box.show();
202202
}
203203
checkSize();
204+
})
205+
.on('click', '.daylight', function() {
206+
$('.nav .home').click();
207+
if(nite.isVisible()) { nite.hide(); }
208+
else { nite.show(); }
204209
});
205210

206211
// toggle functionality for switch button

js/mobile.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/nite-overlay.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
var nite = {
99
map: null,
10+
date: null,
1011
marker_sun: null,
1112
marker_shadow: null,
1213
marker_shadow_lite: null,
@@ -46,6 +47,7 @@ var nite = {
4647
return new google.maps.LatLng(-this.sun_position.lat(), -this.sun_position.lng() + 180);
4748
},
4849
refresh: function() {
50+
if(!this.isVisible()) return;
4951
this.refreshSunZenith();
5052
this.marker_shadow.setCenter(this.getShadowPosition());
5153
this.marker_shadow_lite.setCenter(this.getShadowPosition());
@@ -55,6 +57,7 @@ var nite = {
5557

5658
// based on NOAA solar calculations
5759
var utc = new Date();
60+
if(this.date) { utc = new Date(this.date); }
5861
utc = new Date(utc.getTime() + utc.getTimezoneOffset() * 60000);
5962
var mins_past_midnight = (utc.getHours() * 60 + utc.getMinutes()) / 1440;
6063
var jd = 2415018.5 - ((new Date("01/01/1900 00:00:00 UTC")).getTime() - utc.getTime()) / 1000 / 60 / 60 / 24;
@@ -77,15 +80,23 @@ var nite = {
7780

7881
this.sun_position = new google.maps.LatLng(lat, lng);
7982
},
83+
setDate: function(date) {
84+
this.date = date;
85+
this.refresh();
86+
},
8087
setMap: function(map) {
8188
this.map = map;
8289
},
8390
show: function() {
8491
this.marker_shadow.setVisible(true);
8592
this.marker_shadow_lite.setVisible(true);
93+
this.refresh();
8694
},
8795
hide: function() {
8896
this.marker_shadow.setVisible(false);
8997
this.marker_shadow_lite.setVisible(false);
98+
},
99+
isVisible: function() {
100+
return this.marker_shadow.getVisible();
90101
}
91102
}

js/tracker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function load() {
5252
});
5353

5454
nite.init(map);
55+
nite.hide();
5556
setInterval(function() { nite.refresh(); }, 60000); // 1min
5657

5758
// we need a dummy overlay to access getProjection()

0 commit comments

Comments
 (0)