[
Denunciar] [
Ocultar]'
- );
+ brd + "/" + id + '">Denunciar] [
Ocultar]');
this.getElementsByClassName("hh")[0].addEventListener("click", function(e) {
document.getElementById("cat" + id + brd).style.display = "none";
hiddenthreads.push(id + brd);
@@ -403,9 +352,7 @@ function catHidden() {
e.preventDefault();
for (var i = 0; i < hiddenthreads.length; i++) {
try {
- document
- .getElementById("cat" + hiddenthreads[i])
- .removeAttribute("style");
+ document.getElementById("cat" + hiddenthreads[i]).removeAttribute("style");
} catch (err) {
continue;
}
@@ -437,28 +384,6 @@ function applyTheme() {
set_stylesheet(newTheme);
}
-function readableSize(B) {
- var thresh = 1024;
- if (Math.abs(B) < thresh) return B + " B";
- var units = ["KB", "MB", "GB"];
- var u = -1;
- do {
- B /= thresh;
- ++u;
- } while (Math.abs(B) >= thresh && u < units.length - 1);
- return B.toFixed(1) + " " + units[u];
-}
-
-function fixFileSize() {
- var obj = document.getElementsByClassName("fs");
- for (var i = 0; i < obj.length; i++) {
- var parts = obj[i].childNodes[2].textContent.split(" B, ");
- var filesize = parts[0].substring(2);
- obj[i].childNodes[2].textContent =
- "-(" + readableSize(filesize) + ", " + parts[1];
- }
-}
-
document.addEventListener("DOMContentLoaded", function(e) {
checkhighlight();
if (localStorage.hasOwnProperty("weabot"))
@@ -474,33 +399,13 @@ document.addEventListener("DOMContentLoaded", function(e) {
}
}
- if (screen.width < 720) {
- var head = document.getElementById("main_nav");
- var b = head.getElementsByTagName("a");
- var s = document.createElement("select");
- for (var i = 1; i < b.length; i++) {
- var o = document.createElement("option");
- o.value = b[i].href;
- o.textContent = b[i].textContent;
- if (b[i].className == "cur_brd") o.defaultSelected = true;
- s.appendChild(o);
- }
- s.addEventListener("change", function(e) {
- window.location.href = this.value;
- });
- head.removeChild(head.childNodes[0]);
- head.className = "mob fix";
- head.insertBefore(s, head.childNodes[0]);
- }
-
if (localStorage.hasOwnProperty("hiddenthreads")) {
hiddenthreads = localStorage.getItem("hiddenthreads").split("!");
if (document.getElementById("catalog")) {
hidden_num = 0;
for (var i = 0; i < hiddenthreads.length; i++) {
try {
- document.getElementById("cat" + hiddenthreads[i]).style.display =
- "none";
+ document.getElementById("cat" + hiddenthreads[i]).style.display = "none";
hidden_num++;
} catch (err) {
continue;
@@ -512,11 +417,8 @@ document.addEventListener("DOMContentLoaded", function(e) {
} else {
for (var i = 0; i < hiddenthreads.length; i++) {
try {
- document
- .getElementById("unhide" + hiddenthreads[i])
- .removeAttribute("style");
- document.getElementById("thread" + hiddenthreads[i]).style.display =
- "none";
+ document.getElementById("unhide" + hiddenthreads[i]).removeAttribute("style");
+ document.getElementById("thread" + hiddenthreads[i]).style.display = "none";
} catch (err) {
continue;
}
@@ -529,14 +431,10 @@ document.addEventListener("DOMContentLoaded", function(e) {
styleSelect.addEventListener("change", applyTheme, false);
styleSelect.value = localStorage.getItem(style_cookie);
}
-
+
if (document.getElementById("postform")) {
setInputs("postform");
- maxsize = document.getElementById("maxsize").innerText;
- types = document.getElementById("filetypes").innerText.split(", ");
- if (types.includes("JPG")) types.push("JPEG");
postform.file.addEventListener("change", filePreview);
- fixFileSize();
}
var del = document.getElementById("delform");
@@ -583,25 +481,21 @@ document.addEventListener("DOMContentLoaded", function(e) {
}
}
});
-document.addEventListener(
- "click",
- function(e) {
- var cn = e.target.className;
- if (cn == "num") {
- e.preventDefault();
- postClick(e.target.textContent);
- return;
- }
- if (cn == "tt") {
- e.preventDefault();
- togglethread(e.target);
- return;
- }
- if (cn == "expimg") {
- e.preventDefault();
- expandimg(e.target);
- return;
- }
- },
- false
-);
+document.addEventListener("click", function(e) {
+ var cn = e.target.className;
+ if (cn == "num") {
+ e.preventDefault();
+ postClick(e.target.textContent);
+ return;
+ }
+ if (cn == "tt") {
+ e.preventDefault();
+ togglethread(e.target);
+ return;
+ }
+ if (cn == "expimg") {
+ e.preventDefault();
+ expandimg(e.target);
+ return;
+ }
+}, false);
diff --git a/static/js/weabotxt.js b/static/js/weabotxt.js
index ba3e51d..cf4209a 100644
--- a/static/js/weabotxt.js
+++ b/static/js/weabotxt.js
@@ -11,17 +11,6 @@ function set_stylesheet(styletitle) {
localStorage.setItem(style_cookie, styletitle);
}
-function timeMob(timestamp) {
- var time = Math.round(Date.now() / 1000);
- var el = time - timestamp;
- if (el < 60) return el + "s";
- else if (el < 3600) return Math.round(el / 60) + "m";
- else if (el < 86400) return Math.round(el / 3600) + "h";
- else if (el < 2628000) return Math.round(el / 86400) + "d";
- else if (el < 31536000) return Math.round(el / 2628000) + "me";
- else return Math.round(el / 31557600) + "a";
-}
-
/* IE/Opera fix, because they need to go learn a book on how to use indexOf with arrays */
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(elt /*, from*/) {
@@ -82,9 +71,8 @@ function insert(text) {
// IE
var caretPos = textarea.caretPos;
caretPos.text =
- caretPos.text.charAt(caretPos.text.length - 1) == " "
- ? text + " "
- : text;
+ caretPos.text.charAt(caretPos.text.length - 1) ==
+ " " ? text + " " : text;
} else if (textarea.setSelectionRange) {
// Firefox
var start = textarea.selectionStart;
@@ -106,14 +94,8 @@ function deletePost(e) {
var realid = ids.pop();
if (confirm("¿Seguro que deseas borrar el mensaje " + post + "?")) {
var script = "/cgi/delete";
- document.location =
- script +
- "?board=" +
- board +
- "&password=" +
- weabot.password +
- "&delete=" +
- realid;
+ document.location = script + "?board=" + board + "&password=" +
+ weabot.password + "&delete=" + realid;
}
}
@@ -139,10 +121,9 @@ function previewPost(e) {
if (main) main.style.display = "";
preview.removeAttribute("style");
- preview.innerHTML = "
Cargando...";
+ preview.innerText = "Cargando...";
- var text =
- "message=" + encodeURIComponent(form.message.value) + "&board=" + board;
+ var text = "message=" + encodeURIComponent(form.message.value) + "&board=" + board;
if (thread) text += "&parentid=" + thread;
var xmlhttp = get_xmlhttp();
@@ -151,10 +132,7 @@ function previewPost(e) {
if (xmlhttp.readyState == 4) preview.innerHTML = xmlhttp.responseText;
};
if (is_ie() || xmlhttp.setRequestHeader)
- xmlhttp.setRequestHeader(
- "Content-Type",
- "application/x-www-form-urlencoded"
- );
+ xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(text);
}
@@ -166,31 +144,21 @@ function listSort() {
arr.shift();
if (s == "Normal") {
arr.sort(function(a, b) {
- return (
- parseInt(a.childNodes[1].textContent) -
- parseInt(b.childNodes[1].textContent)
- );
+ return (parseInt(a.childNodes[1].textContent) - parseInt(b.childNodes[1].textContent));
});
} else if (s == "Edad") {
arr.sort(function(a, b) {
- return (
- b.children[1].firstChild.href.split("/")[5] -
- a.children[1].firstChild.href.split("/")[5]
- );
+ return (b.children[1].firstChild.href.split("/")[5] - a.children[1].firstChild.href.split("/")[5]);
});
} else if (s == "Largo") {
arr.sort(function(a, b) {
- return b.children[2].textContent - a.children[2].textContent;
+ return (b.children[2].textContent - a.children[2].textContent);
});
} else if (s == "Rapidez") {
var now = Math.round(Date.now() / 1000);
arr.sort(function(a, b) {
- return (
- b.children[2].textContent /
- (now - b.children[1].firstChild.href.split("/")[5]) -
- a.children[2].textContent /
- (now - a.children[1].firstChild.href.split("/")[5])
- );
+ return (b.children[2].textContent / (now - b.children[1].firstChild.href.split("/")[5]) -
+ a.children[2].textContent / (now - a.children[1].firstChild.href.split("/")[5]));
});
} else if (s == "Aleatorio") {
arr.sort(function(a, b) {
@@ -296,37 +264,6 @@ document.addEventListener("DOMContentLoaded", function() {
}
}
- var dt = document.getElementsByClassName("date");
- if (screen.width < 720) {
- if (head) {
- var b = head.getElementsByTagName("a");
- var s = document.createElement("select");
- for (var i = 1; i < b.length; i++) {
- var o = document.createElement("option");
- o.value = b[i].href;
- o.textContent = b[i].textContent;
- if (b[i].className == "cur_brd") o.defaultSelected = true;
- s.appendChild(o);
- }
- s.addEventListener("change", function(e) {
- window.location.href = this.value;
- });
- head.innerHTML = '
Bienvenido a Internet | ';
- head.appendChild(s);
- head.removeAttribute("style");
- document.body.className += " fix";
- var head2 = document.getElementById("thread_nav");
- if (head2) head2.removeChild(head2.childNodes[1]);
- }
-
- for (var i = 0; i < dt.length; i++) {
- t = dt[i].textContent;
- if (t.includes("ID:")) var id = t.split(" ")[1];
- else id = "";
- dt[i].textContent = "Hace " + timeMob(dt[i].dataset.unix) + " " + id;
- }
- }
-
var forms = document.getElementsByTagName("form");
for (var i = 0; i < forms.length; i++) {
if (forms[i].id.startsWith("postform")) setInputs(forms[i].id);
@@ -369,6 +306,7 @@ document.addEventListener("DOMContentLoaded", function() {
if (localStorage.hasOwnProperty("hiddenposts"))
hiddenposts = localStorage.getItem("hiddenposts").split("!");
+ var dt = document.getElementsByClassName("date");
for (var i = 0; i < dt.length; i++) {
if (hiddenposts.includes(board + dt[i].dataset.unix)) {
console.log(dt[i].dataset.unix);
@@ -377,20 +315,17 @@ document.addEventListener("DOMContentLoaded", function() {
dt[i].parentElement.addEventListener("dblclick", togglepost);
}
});
-document.addEventListener(
- "click",
- function(e) {
- var txt = e.target.textContent;
- if (e.target.className == "num") {
- e.preventDefault();
- postClick(txt);
- return;
- }
- if (txt == "del") {
- e.preventDefault();
- deletePost(e.target);
- return;
- }
- },
- false
-);
+
+document.addEventListener("click", function(e) {
+ var txt = e.target.textContent;
+ if (e.target.className == "num") {
+ e.preventDefault();
+ postClick(txt);
+ return;
+ }
+ if (txt == "del") {
+ e.preventDefault();
+ deletePost(e.target);
+ return;
+ }
+}, false);
--
cgit v1.2.1-18-gbd029