blob: dfef44604d8c3f1779a8be9baa4bdee2d6430a59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// Highlight
hljs.initHighlightingOnLoad();
// 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');
}
});
|