more themes and final changes to script for now

merge-requests/208/head
fatchan 5 years ago
parent 34b97321c1
commit 3823fce7be
  1. 28
      gulp/res/css/themes/rei-zero.css
  2. 2
      gulp/res/css/themes/sushi.css
  3. 34
      gulp/res/js/theme.js

@ -0,0 +1,28 @@
/*rei-zero*/
:root {
--background-top: #000E1C;
--background-rest: #000E1C;
--navbar-color: #29373E;
--post-color: #29373E;
--post-outline-color: #666666;
--label-color: #29373E;
--box-border-color: #000;
--darken: #00000010;
--highlighted-post-color: #193A3A;
--highlighted-post-outline-color: #999999;
--board-title: #193A3A;
--hr: #474747;
--font-color: #D6D6D6;
--name-color: #117743;
--capcode-color: #f00;
--subject-color: #CCCCCC;
--link-color: #5C99AD;
--post-link-color: #00BfFF;
--link-hover: #eeeeee;
--input-borders: #a9a9a9;
--input-color: lightgray;
--input-background: #001229;
--dice-color: darkorange;
--title-color: #d70000;
--greentext-color: #789922;
}

@ -9,7 +9,7 @@
--box-border-color: #8FCCCD;
--darken: #00000010;
--highlighted-post-color: #a9d8ff;
--highlighted-post-outline-color: #a9d8ff;
--highlighted-post-outline-color: #8FCCCD;
--board-title: #800000;
--hr: #B7D9C5;
--font-color: black;

@ -8,43 +8,43 @@ function changeTheme(e) {
//add theme setting to localstorage
localStorage.setItem('theme', theme);
//check for theme style tag
var custom = document.getElementById('customtheme');
var tempLink = document.getElementById('customtheme');
if (theme === 'default') {
if (custom) {
if (tempLink) {
//remove theme style tag if we switching to default
custom.remove();
tempLink.remove();
}
} else {
//path of the theme css
var path = '/css/themes/'+theme+'.css';
//get the raw css from localstorage
var css = localStorage.getItem(path);
if (!custom) {
if (!tempLink) {
//create the style tag if it doesnt exist
custom = document.createElement('style');
custom.id = 'customtheme';
document.head.appendChild(custom);
tempLink = document.createElement('style');
document.head.appendChild(tempLink);
}
if (css) {
//if we have the css in localstorage, set it (prevents FOUC)
custom.innerHTML = css;
tempLink.innerHTML = css;
}
//then createa new link rel=stylesheet, and load the css
var tempLink = document.createElement('link');
tempLink.rel = 'stylesheet';
tempLink.onload = function() {
var themeLink = document.createElement('link');
themeLink.rel = 'stylesheet';
themeLink.id = 'customtheme';
themeLink.onload = function() {
css = '';
for(var i = 0; i < tempLink.sheet.rules.length; i++) {
css += tempLink.sheet.rules[i].cssText;
for(var i = 0; i < themeLink.sheet.rules.length; i++) {
css += themeLink.sheet.rules[i].cssText;
}
//update our localstorage with latest version
localStorage.setItem(path, css);
custom.innerHTML = css;
tempLink.innerHTML = css;
//immediately remove it since we dont need it
custom.remove();
tempLink.remove();
}
tempLink.href = path;
document.head.appendChild(tempLink);
themeLink.href = path;
document.head.appendChild(themeLink);
}
}

Loading…
Cancel
Save