Fixed relative path issue with theme switcher, changed to absolute path

This commit is contained in:
Phuntsok Drak-pa 2019-09-29 13:29:47 +02:00
parent 57eb8166ec
commit 7cfdc4f1c4
1 changed files with 5 additions and 1 deletions

View File

@ -39,17 +39,21 @@ function reorganize_html() {
function create_theme_switcher() { function create_theme_switcher() {
// set the correct CSS depending on the cookie, dark is default // set the correct CSS depending on the cookie, dark is default
var light = isThemeLight(); var light = isThemeLight();
// Set the correct symbol in the theme switcher button
$('body').append('<div class="themeBtn"><i class="fas fa-' $('body').append('<div class="themeBtn"><i class="fas fa-'
.concat(light ? 'moon' : 'sun').concat('"></i></div>')); .concat(light ? 'moon' : 'sun').concat('"></i></div>'));
// set the correct css file in the HTML head
$('head').append('<link id="theme" rel="stylesheet" href="https://langue.phundrak.fr/css/' $('head').append('<link id="theme" rel="stylesheet" href="https://langue.phundrak.fr/css/'
.concat(light ? 'light' : 'dark').concat('.css">')); .concat(light ? 'light' : 'dark').concat('.css">'));
// switch CSS files and button icon, set new cookie on theme switcher click // switch CSS files and button icon, set new cookie on theme switcher click
$('.themeBtn').click(function() { $('.themeBtn').click(function() {
var light = !isThemeLight(); var light = !isThemeLight();
$("#theme").first().attr('href', './css/' // Switch the CSS between light and dark
$("#theme").first().attr('href', 'https://langue.phundrak.fr/css/'
.concat(light ? 'light' : 'dark') .concat(light ? 'light' : 'dark')
.concat('.css')); .concat('.css'));
// Switch the icon in the theme switcher button
$('.themeBtn').html('<i class="fas fa-' $('.themeBtn').html('<i class="fas fa-'
.concat(light ? 'moon' : 'sun') .concat(light ? 'moon' : 'sun')
.concat('"></i>')); .concat('"></i>'));