default theme option and slight improvement to head template

merge-requests/208/head
fatchan 5 years ago
parent 47280caced
commit b85afbb0db
  1. 15
      gulp/res/js/theme.js
  2. 4
      views/includes/footer.pug
  3. 6
      views/includes/head.pug
  4. 4
      views/includes/themeswitcher.pug

@ -1,11 +1,20 @@
function changeTheme(e) {
var theme = e ? this.value : localStorage.getItem('theme');
if (!theme) {
return;
theme = 'default';
}
localStorage.setItem('theme', theme)
localStorage.setItem('theme', theme);
var themeLink = document.getElementById('theme');
themeLink.href = '/css/themes/'+theme+'.css';
//if somebody makes a theme file named "default", it wont work. so just dont.
if (theme === 'default') {
var defaultTheme = themeLink.dataset.theme;
var defaultHref = '/css/themes/'+defaultTheme+'.css';
if (themeLink.href !== defaultHref) {
themeLink.href = '/css/themes/'+defaultTheme+'.css';
}
} else {
themeLink.href = '/css/themes/'+theme+'.css';
}
}
changeTheme();

@ -6,6 +6,4 @@ small.footer#bottom
| -
a(href='https://github.com/fatchan/jschan/') source code
| -
select.jsonly#theme-changer(name='theme')
each theme in themes
option(value=theme) #{theme}
include ./themeswitcher.pug

@ -1,10 +1,8 @@
meta(charset='utf-8')
meta(name='viewport', content='width=device-width, initial-scale=1')
link(rel='stylesheet' href='/css/style.css')
if board && board.settings.theme
link#theme(rel='stylesheet' href=`/css/themes/${board.settings.theme}.css`)
else
link#theme(rel='stylesheet' href=`/css/themes/${defaultTheme}.css`)
- const theme = board ? board.settings.theme : defaultTheme;
link#theme(rel='stylesheet' data-theme=theme href=`/css/themes/${theme}.css`)
noscript
style
| .jsonly { display: none }

@ -0,0 +1,4 @@
select.jsonly#theme-changer(name='theme')
option(value='default') default
each theme in themes
option(value=theme) #{theme}
Loading…
Cancel
Save