Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions examples/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$(document).ready(() => {
let body=document.querySelector('body');
let toggleButton=document.getElementById('myonoffswitch');
let toggle = localStorage.getItem('currentToggle');
let toggle = localStorage.getItem('currentToggle') || 'day';

// Sets images' theme accordingly when the page is loaded
setTimeout(()=> {
Expand Down Expand Up @@ -57,10 +57,10 @@

setTimeout(()=> {
let images=document.querySelectorAll("img");
let check=localStorage.getItem('currentToggle');

if(check==="night") {
if(toggle==="night") {
localStorage.setItem('currentToggle', 'day');
toggle = 'day';
body.style.backgroundColor = '#f8f8fa';
body.style.filter = 'invert(0)';
body.style.transitionProperty = 'filter';
Expand All @@ -80,6 +80,7 @@

}else {
localStorage.setItem('currentToggle', 'night');
toggle = 'night';
body.style.backgroundColor = '#111111';
body.style.filter = 'invert(1)';
body.style.transitionProperty = 'filter';
Expand Down Expand Up @@ -131,4 +132,4 @@
$('.past').click((e) => buttonClickCallbackNightTheme(e));
$('.sort-options').click((e) => buttonClickCallbackNightTheme(e));

})
})