Created
January 19, 2018 13:38
-
-
Save imlinus/2cb76a4563aebcf63200496d127acbeb to your computer and use it in GitHub Desktop.
Sun Set Rise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var ymd = '2018-01-19', | |
lat = '59.10', | |
lng = '16.40'; | |
Sun.info(ymd, lat, lng).then(function() { | |
console.log(Sun.rise); | |
console.log(Sun.set); | |
}); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Sun = { | |
rise: '', | |
set: '', | |
cb: '', | |
info: function(ymd, lat, lng) { | |
var that = this; | |
$.get('https://api.sunrise-sunset.org/json?lat=' + lat + '&lng=' + lng + '&date=' + ymd, function(data) { | |
that.rise = data.results.sunrise; | |
that.set = data.results.sunset; | |
that.cb(); | |
}); | |
return this; | |
}, | |
then(cb) { | |
this.cb = cb; | |
return this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment