aboutsummaryrefslogtreecommitdiff
path: root/static/js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js')
-rw-r--r--static/js/weabotxt.js69
1 files changed, 14 insertions, 55 deletions
diff --git a/static/js/weabotxt.js b/static/js/weabotxt.js
index cf4209a..df4bc56 100644
--- a/static/js/weabotxt.js
+++ b/static/js/weabotxt.js
@@ -136,11 +136,11 @@ function previewPost(e) {
xmlhttp.send(text);
}
-function listSort() {
- var s = opcs.sort;
- var cont = document.getElementById("content");
- var elem = document.getElementsByClassName("row");
- var arr = Array.prototype.slice.call(elem);
+function listSort(e) {
+ e.preventDefault();
+ var s = this.textContent;
+ var table = document.getElementById("threads");
+ var arr = Array.prototype.slice.call(table.getElementsByTagName("tr"));
arr.shift();
if (s == "Normal") {
arr.sort(function(a, b) {
@@ -165,37 +165,16 @@ function listSort() {
return 0.5 - Math.random();
});
}
- for (var j = 0; j < arr.length; j++) cont.appendChild(arr[j]);
- localStorage.setItem("threadlist", JSON.stringify(opcs));
-}
-
-function listDisplay() {
- var d = opcs.disp;
- if (d == "Malla") {
- document.getElementById("header").style.display = "none";
- document.getElementById("content").className = "grid";
- var style = document.createElement("style");
- style.id = "labels";
- style.type = "text/css";
- style.textContent =
- '#content .row div.date{display:none}#content.grid div.com:before{content:"("}#content.grid .com:after{content:")"}';
- document.head.appendChild(style);
- } else if (d == "Lista") {
- var style = document.getElementById("labels");
- if (style) style.parentNode.removeChild(style);
- document.getElementById("header").removeAttribute("style");
- document.getElementById("content").className = "list";
- }
- localStorage.setItem("threadlist", JSON.stringify(opcs));
+ for (var j = 0; j < arr.length; j++) table.appendChild(arr[j]);
}
function searchSubjects(e) {
var filter = this.value.toLowerCase();
- var nodes = document.getElementsByClassName("thread");
- for (i = 0; i < nodes.length; i++) {
- if (nodes[i].textContent.toLowerCase().includes(filter))
- nodes[i].parentNode.removeAttribute("style");
- else nodes[i].parentNode.style.display = "none";
+ var nodes = document.getElementById("threads").getElementsByTagName("tr");
+ for (var i = 1; i < nodes.length; i++) {
+ if (nodes[i].childNodes[3].textContent.toLowerCase().includes(filter))
+ nodes[i].removeAttribute("style");
+ else nodes[i].style.display = "none";
}
}
@@ -275,32 +254,12 @@ document.addEventListener("DOMContentLoaded", function() {
styleSelect.value = localStorage.getItem(style_cookie);
}
- if (document.body.classList.contains("threads")) {
+ if (document.getElementById("threads")) {
var srt = document.getElementsByClassName("l_s");
for (var i = 0; i < srt.length; i++) {
- srt[i].addEventListener("click", function(e) {
- e.preventDefault();
- opcs.sort = this.textContent;
- listSort();
- });
- }
- var dsp = document.getElementsByClassName("l_d");
- for (var i = 0; i < dsp.length; i++) {
- dsp[i].addEventListener("click", function(e) {
- e.preventDefault();
- opcs.disp = this.textContent;
- listDisplay();
- });
+ srt[i].addEventListener("click", listSort);
}
document.getElementById("l_sr").addEventListener("keyup", searchSubjects);
- if (localStorage.hasOwnProperty("threadlist")) {
- opcs = JSON.parse(localStorage.getItem("threadlist"));
- listSort();
- listDisplay();
- } else {
- opcs = { sort: "Normal", disp: "Lista" };
- localStorage.setItem("threadlist", JSON.stringify(opcs));
- }
}
if (localStorage.hasOwnProperty("hiddenposts"))
@@ -328,4 +287,4 @@ document.addEventListener("click", function(e) {
deletePost(e.target);
return;
}
-}, false);
+}, false); \ No newline at end of file