From 9b039e42df4eefb7971a2cfa19bce260ab4ef08f Mon Sep 17 00:00:00 2001
From: junk
Date: Sat, 27 Mar 2021 20:20:28 -0300
Subject: Arreglando diseño para móviles
---
static/js/weabotxt.js | 119 ++++++++++++--------------------------------------
1 file changed, 27 insertions(+), 92 deletions(-)
(limited to 'static/js/weabotxt.js')
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