Browse Source

finish theme switcher

Geindre Colin 3 years ago
parent
commit
e2ad52ed3c
1 changed files with 10 additions and 8 deletions
  1. 10
    8
      Y/Scripts/yfold.js

+ 10
- 8
Y/Scripts/yfold.js View File

@@ -133,6 +133,8 @@ window.onload = function() {
133 133
     }
134 134
   }
135 135
 
136
+  var css_url = "/Y/ystyle.css"
137
+
136 138
   if (typeof(Storage) !== "undefined") {
137 139
     var theme = localStorage.getItem("theme");
138 140
     console.log("theme : " + theme)
@@ -160,9 +162,12 @@ window.onload = function() {
160 162
     option.value = opt;
161 163
     option.text = "style " + i.toString();
162 164
     i++;
163
-    console.log(option)
165
+    if (option.value == css_url) {
166
+      option.selected = "selected"
167
+    }
168
+    option.style.outline = "none"
169
+    option.style.border = "none"
164 170
     toggler.appendChild(option);
165
-    console.log("added option")
166 171
   }
167 172
 
168 173
   toggler.style.position = "absolute"
@@ -176,12 +181,9 @@ window.onload = function() {
176 181
   toggler.style.color = "#eee"
177 182
   toggler.style.zIndex = "12"
178 183
   toggler.style.cursor = "pointer"
184
+  toggler.style.outline = "none"
179 185
   toggler.addEventListener("change", function() {
180
-    if (css_url == "/Y/ystyle.css") {
181
-      css_url = "/Y/ystyle2.css";
182
-    } else {
183
-      css_url = "/Y/ystyle.css";
184
-    }
186
+    css_url = toggler.value
185 187
     changeCSS(css_url, 0)
186 188
   })
187 189
 }
@@ -191,7 +193,7 @@ function changeCSS(css_file, cssLinkIndex) {
191 193
     localStorage.setItem("theme", css_file);
192 194
   }
193 195
 
194
-  console.log("changing css")
196
+  console.log("changing css to " + css_file)
195 197
 
196 198
   var oldlink = document.getElementsByTagName("link").item(cssLinkIndex);
197 199
 

Loading…
Cancel
Save