Browse Source

theme switch better url management

Mstrdav 3 years ago
parent
commit
f755c42b88
1 changed files with 14 additions and 4 deletions
  1. 14
    4
      Y/Scripts/yfold.js

+ 14
- 4
Y/Scripts/yfold.js View File

@@ -146,16 +146,22 @@ window.onload = function() {
146 146
     console.log("theme : " + theme)
147 147
     if (theme == "null" || theme == null || theme == "undefined" || theme == undefined) {
148 148
       // Get default value
149
-      css_url = "/Y/ystyle.css";
149
+      css_url = "Y/ystyle.css";
150 150
     } else {
151 151
       css_url = theme;
152
-      changeCSS(css_url, 0)
153 152
     }
153
+
154
+    let position = window.location.href.split("Y")[1].split("/").length - 1
155
+    for (let i = 1; i<=position; i++) {
156
+      css_url = "../" + css_url
157
+    }
158
+
159
+    changeCSS(css_url, 0)
154 160
   }
155 161
 
156 162
   var toggler = document.createElement("select")
157 163
 
158
-  var liste = ["/Y/ystyle.css","/Y/ystyle2.css"];
164
+  var liste = ["Y/ystyle.css","Y/ystyle2.css"];
159 165
 
160 166
   toggler.id = "toggler";
161 167
   document.body.appendChild(toggler)
@@ -168,7 +174,7 @@ window.onload = function() {
168 174
     option.value = opt;
169 175
     option.text = "style " + i.toString();
170 176
     i++;
171
-    if (option.value == css_url) {
177
+    if (option.value == css_url.split("../")[css_url.split("../").length - 1]) {
172 178
       option.selected = "selected"
173 179
     }
174 180
     option.style.outline = "none"
@@ -190,6 +196,10 @@ window.onload = function() {
190 196
   toggler.style.outline = "none"
191 197
   toggler.addEventListener("change", function() {
192 198
     css_url = toggler.value
199
+    let position = window.location.href.split("Y")[1].split("/").length - 1
200
+    for (let i = 1; i<=position; i++) {
201
+      css_url = "../" + css_url
202
+    }
193 203
     changeCSS(css_url, 0)
194 204
   })
195 205
 }

Loading…
Cancel
Save