hugo-theme-wondermod/static/main.js

18 lines
577 B
JavaScript
Raw Normal View History

2019-10-14 19:31:07 +02:00
// Highlight
2019-09-15 00:55:10 +02:00
hljs.initHighlightingOnLoad();
2019-10-14 19:31:07 +02: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-15 00:55:10 +02:00
}
2019-10-14 19:31:07 +02:00
});