|
45 | 45 | <div class="window-body"> |
46 | 46 | {% include nav.html %} |
47 | 47 | <div style="margin-top: .5em;"> |
48 | | - <select> |
49 | | - <option id="stylesheet1">XP Theme</option> |
50 | | - <option id="stylesheet2">98 Theme</option> |
51 | | - <option id="stylesheet3">7 Theme</option> |
| 48 | + <select id="theme-selector"> |
| 49 | + <option id="xp-style" value="0">XP Theme</option> |
| 50 | + <option id="98-style" value="1">98 Theme</option> |
| 51 | + <option id="7-style" value="2">7 Theme</option> |
52 | 52 | </select> |
53 | 53 | </div> |
54 | 54 | </div> |
|
76 | 76 | </body> |
77 | 77 |
|
78 | 78 | <script> |
| 79 | + window.addEventListener('load', initialize, false); |
| 80 | + window.addEventListener('load', loadTheme, false); |
| 81 | + |
79 | 82 | function swapStyleSheet(sheet) { |
80 | 83 | document.getElementById("pagestyle").setAttribute("href", sheet); |
81 | 84 | } |
82 | 85 |
|
83 | | - function initate() { |
84 | | - var style1 = document.getElementById("stylesheet1"); |
85 | | - var style2 = document.getElementById("stylesheet2"); |
86 | | - var style3 = document.getElementById("stylesheet3"); |
| 86 | + function initialize() { |
| 87 | + let XPStyle = document.getElementById("xp-style"); |
| 88 | + let ninetyEightStyle = document.getElementById("98-style"); |
| 89 | + let sevenStyle = document.getElementById("7-style"); |
87 | 90 |
|
88 | | - style1.onclick = function () { |
| 91 | + XPStyle.onclick = function () { |
89 | 92 | swapStyleSheet("https://unpkg.com/xp.css"); |
90 | | - localStorage.setItem("theme", "https://unpkg.com/xp.css"); |
91 | | - }; |
92 | | - style2.onclick = function () { |
| 93 | + localStorage.setItem("theme", "XP"); |
| 94 | + } |
| 95 | + ninetyEightStyle.onclick = function () { |
93 | 96 | swapStyleSheet("https://unpkg.com/xp.css@0.2.3/dist/98.css"); |
94 | | - localStorage.setItem("theme", "https://unpkg.com/xp.css@0.2.3/dist/98.css"); |
95 | | - }; |
96 | | - style3.onclick = function () { |
| 97 | + localStorage.setItem("theme", "98"); |
| 98 | + } |
| 99 | + sevenStyle.onclick = function () { |
97 | 100 | swapStyleSheet("https://unpkg.com/7.css") |
98 | | - localStorage.setItem("theme", "https://unpkg.com/7.css"); |
99 | | - }; |
| 101 | + localStorage.setItem("theme", "7"); |
| 102 | + } |
100 | 103 | } |
101 | 104 |
|
102 | | - window.onload = function () { |
103 | | - if (localStorage.getItem("theme") == "https://unpkg.com/xp.css") { |
104 | | - swapStyleSheet("https://unpkg.com/xp.css"); |
105 | | - } else if (localStorage.getItem("theme") == "https://unpkg.com/xp.css@0.2.3/dist/98.css") { |
106 | | - swapStyleSheet("https://unpkg.com/xp.css@0.2.3/dist/98.css"); |
107 | | - } else if (localStorage.getItem("theme") == "https://unpkg.com/7.css") { |
108 | | - swapStyleSheet("https://unpkg.com/7.css"); |
| 105 | + function loadTheme() { |
| 106 | + let currentTheme = localStorage.getItem("theme"); |
| 107 | + let themeSelect = document.getElementById("theme-selector"); |
| 108 | + |
| 109 | + switch (currentTheme) { |
| 110 | + case "XP": |
| 111 | + swapStyleSheet("https://unpkg.com/xp.css"); |
| 112 | + themeSelect.value = "0"; |
| 113 | + break |
| 114 | + case "98": |
| 115 | + swapStyleSheet("https://unpkg.com/98.css"); |
| 116 | + themeSelect.value = "1"; |
| 117 | + break |
| 118 | + case "7": |
| 119 | + swapStyleSheet("https://unpkg.com/7.css"); |
| 120 | + themeSelect.value = "2"; |
| 121 | + break |
109 | 122 | } |
110 | | - initate(); |
111 | 123 | } |
112 | 124 | </script> |
0 commit comments