|
|
@ -68,38 +68,36 @@ $(document).on('input keypress paste keyup', 'input[data-autoalias]', function ( |
|
|
|
$(function () { |
|
|
|
$(function () { |
|
|
|
// theme switcher without reloading
|
|
|
|
// theme switcher without reloading
|
|
|
|
|
|
|
|
|
|
|
|
let themeStyle = document.querySelector('#theme-style'); |
|
|
|
let themeStyle = $('#theme-style'); |
|
|
|
const lightURL = themeStyle.getAttribute('light-url'); |
|
|
|
const lightURL = themeStyle.data('light-url'); |
|
|
|
const darkURL = themeStyle.getAttribute('dark-url'); |
|
|
|
const darkURL = themeStyle.data('dark-url'); |
|
|
|
const navbar = document.querySelector('.page-navbar'); |
|
|
|
const navbar = $('.page-navbar'); |
|
|
|
const logo = document.querySelector('#navbar-logo'); |
|
|
|
const logo = $('#navbar-logo'); |
|
|
|
|
|
|
|
|
|
|
|
window.toggleDarkMode = function () { |
|
|
|
window.toggleDarkMode = function () { |
|
|
|
let newStyle = document.createElement('link'); |
|
|
|
let newStyle = document.createElement('link'); |
|
|
|
newStyle.rel = 'stylesheet'; |
|
|
|
newStyle.rel = 'stylesheet'; |
|
|
|
if (themeStyle.href === lightURL) { |
|
|
|
if (themeStyle.attr('href') === lightURL) { |
|
|
|
newStyle.href = darkURL; |
|
|
|
newStyle.href = darkURL; |
|
|
|
navbar.classList.remove('navbar-light'); |
|
|
|
navbar.removeClass('navbar-light'); |
|
|
|
navbar.classList.add('navbar-dark'); |
|
|
|
navbar.addClass('navbar-dark'); |
|
|
|
logo.src = logo.getAttribute('src-dark'); |
|
|
|
logo.attr('src', logo.data('src-dark')); |
|
|
|
|
|
|
|
|
|
|
|
document.cookie = "dark_mode=1"; |
|
|
|
document.cookie = "dark_mode=1"; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
newStyle.href = lightURL; |
|
|
|
newStyle.href = lightURL; |
|
|
|
navbar.classList.remove('navbar-dark'); |
|
|
|
navbar.removeClass('navbar-dark'); |
|
|
|
navbar.classList.add('navbar-light'); |
|
|
|
navbar.addClass('navbar-light'); |
|
|
|
logo.src = logo.getAttribute('src-light'); |
|
|
|
logo.attr('src', logo.data('src-light')); |
|
|
|
|
|
|
|
|
|
|
|
document.cookie = "dark_mode=0;expires=" + new Date().toUTCString(); |
|
|
|
document.cookie = "dark_mode=0;expires=" + new Date().toUTCString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// remove old css after new css has loaded to prevent FOUC
|
|
|
|
// remove old css after new css has loaded to prevent FOUC
|
|
|
|
let oldThemeStyle = themeStyle; |
|
|
|
let oldThemeStyle = themeStyle; |
|
|
|
themeStyle = newStyle; |
|
|
|
themeStyle = $(newStyle); |
|
|
|
newStyle.addEventListener('load', () => { |
|
|
|
themeStyle.on('load', () => oldThemeStyle.remove()); |
|
|
|
document.head.removeChild(oldThemeStyle); |
|
|
|
$(document.head).append(themeStyle); |
|
|
|
}); |
|
|
|
|
|
|
|
document.head.appendChild(newStyle); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|