Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
dberezansky committed Dec 21, 2021
1 parent 2b5da8a commit be76ba5
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions Front-End/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,20 @@ function toggleWeatherPopup() {
}
}

// Sets theme by cookie if exists or by OS theme if no cookie exists.
window.onload=function() {
var cookie_pos = document.cookie.indexOf('theme='); // locates cookie
if (cookie_pos != -1) { // if exists cookie
var cookieTheme = substr(cookie_pos + 10, document.cookie.indexOf(';', cookie_pos)); // extracts cookie
if (cookieTheme == "dark") {
darkMode();
} else {
lightMode();
}
} else {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
darkMode();
}
}
// Sets site theme by cookie if exists.
// var cookie_pos = document.cookie.indexOf('theme='); // locates cookie
// if (cookie_pos != -1) { // if exists cookie
// var cookieTheme = substr(cookie_pos + 10, document.cookie.indexOf(';', cookie_pos)); // extracts cookie
// if (cookieTheme == 'dark') {
// darkMode();
// } else {
// lightMode();
// }
// }

// Sets site theme by OS theme.
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
darkMode();
}

// Toggles the overall site theme.
Expand Down

0 comments on commit be76ba5

Please sign in to comment.