aboutsummaryrefslogtreecommitdiff
path: root/static/js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js')
-rw-r--r--static/js/weabotxt.js23
1 files changed, 12 insertions, 11 deletions
diff --git a/static/js/weabotxt.js b/static/js/weabotxt.js
index 37668d8..91e2ab0 100644
--- a/static/js/weabotxt.js
+++ b/static/js/weabotxt.js
@@ -1,5 +1,7 @@
var style_cookie = "weabot_style_txt";
-if(style_cookie && localStorage.hasOwnProperty(style_cookie)) { set_stylesheet(localStorage.getItem(style_cookie)); }
+if(style_cookie && localStorage.hasOwnProperty(style_cookie)) {
+ set_stylesheet(localStorage.getItem(style_cookie));
+}
var hiddenposts = Array();
@@ -240,6 +242,11 @@ function togglepost(e) {
localStorage.setItem("hiddenposts", hiddenposts.join("!"));
}
+function applyTheme(){
+ var newTheme = document.getElementById("themeSelector").value;
+ set_stylesheet(newTheme);
+}
+
document.addEventListener("DOMContentLoaded", function() {
if (localStorage.hasOwnProperty("weabot")) weabot = JSON.parse(localStorage.getItem("weabot"));
else weabot = {"name":null,"email":null,"password":null};
@@ -256,16 +263,10 @@ document.addEventListener("DOMContentLoaded", function() {
var forms = document.getElementsByTagName("form");
for(var i=0;i<forms.length;i++) { if(forms[i].id.startsWith("postform")) setInputs(forms[i].id); }
- var sss = document.getElementsByClassName("ss");
- var style = localStorage.getItem(style_cookie);
- for(var i=0;i<sss.length;i++) {
- sss[i].addEventListener("click", function() {
- set_stylesheet(this.textContent);
- var cur = document.getElementById("cur_stl");
- if (cur) cur.removeAttribute("id");
- this.id = "cur_stl";
- });
- if (sss[i].innerText == style) sss[i].id = "cur_stl";
+ if (document.body.className == "mainpage") {
+ var themeSelector = document.getElementById("themeSelector");
+ themeSelector.addEventListener("change", applyTheme, false);
+ themeSelector.value = localStorage.getItem(style_cookie);
}
var dds = document.getElementsByClassName("del");