PaperModX/static/main.js

18 lines
577 B
JavaScript
Raw Normal View History

2019-10-14 18:31:07 +01:00
// Highlight
2019-09-14 23:55:10 +01:00
hljs.initHighlightingOnLoad();
2019-10-14 18:31:07 +01:00
// SunriseSunset
const getSunrise = SunriseSunsetJS.getSunrise;
const getSunset = SunriseSunsetJS.getSunset;
navigator.geolocation.getCurrentPosition((position) => {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
const sunrise = getSunrise(latitude, longitude).getTime();
const sunset = getSunset(latitude, longitude).getTime();
const now = Date.now();
if (now < sunrise || now < sunset) {
const body = document.querySelector('body');
body.classList.add('dark');
2019-09-14 23:55:10 +01:00
}
2019-10-14 18:31:07 +01:00
});