diff --git a/src/gui/theming.js b/src/gui/theming.js index fa248354326bc71eddf2f0a0d2772d932c91887a..038a21fcf6d06b9441daf2852408d1fbf375dafe 100644 --- a/src/gui/theming.js +++ b/src/gui/theming.js @@ -7,7 +7,7 @@ App.UI.Theme = (function() { // reload theme on page reload $(document).on(":passagestart", () => { - if (currentThemeElement === null && V.theme !== 0) { + if (currentThemeElement === null && V.theme !== 0 && V.theme !== undefined) { load(V.theme); } }); @@ -46,10 +46,7 @@ App.UI.Theme = (function() { function load(filename) { V.theme = filename; - currentThemeElement = document.createElement("link"); - currentThemeElement.setAttribute("rel", "stylesheet"); - currentThemeElement.setAttribute("type", "text/css"); - currentThemeElement.setAttribute("href", `./${filename}`); + currentThemeElement = newTheme(filename); document.head.appendChild(currentThemeElement); } @@ -72,16 +69,21 @@ App.UI.Theme = (function() { devTheme = null; } - if (name !== undefined) { - devTheme = document.createElement("link"); - devTheme.setAttribute("rel", "stylesheet"); - devTheme.setAttribute("type", "text/css"); - devTheme.setAttribute("href", `./${filename}`); + if (filename !== undefined) { + devTheme = newTheme(filename); document.head.appendChild(devTheme); } } + function newTheme(filename) { + const theme = document.createElement("link"); + theme.setAttribute("rel", "stylesheet"); + theme.setAttribute("type", "text/css"); + theme.setAttribute("href", `./${filename}`); + return theme; + } + /** * @param {object} V */