aboutsummaryrefslogtreecommitdiff
path: root/static/js/weabotxt.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/weabotxt.js')
-rw-r--r--static/js/weabotxt.js67
1 files changed, 44 insertions, 23 deletions
diff --git a/static/js/weabotxt.js b/static/js/weabotxt.js
index 13911da..1301387 100644
--- a/static/js/weabotxt.js
+++ b/static/js/weabotxt.js
@@ -11,6 +11,17 @@ 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*/) {
@@ -203,29 +214,40 @@ document.addEventListener("DOMContentLoaded", function() {
else weabot = {"name":null,"email":null,"password":null};
board = document.body.dataset.brd;
- var main = document.getElementById("main_nav");
- if (main) {
- var b = main.getElementsByTagName("a");
+ var head = document.getElementById("main_nav");
+ if (head) {
+ var b = head.getElementsByTagName("a");
for(var i=0; i<b.length; i++) {
if (b[i].getAttribute("href") == "/"+board+"/") { b[i].className = "cur_brd"; break; }
}
}
+ var dt = document.getElementsByClassName("date");
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);
+ 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 = '<a href="/" target="_top">Bienvenido a Internet</a> | ';
+ 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;
}
- s.addEventListener("change", function(e){ window.location.href=this.value; });
- head.className = "mob fix";
- head.innerHTML = '<a href="/" target="_top">Bienvenido a Internet</a> | ';
- head.appendChild(s);
}
var forms = document.getElementsByTagName("form");
@@ -237,7 +259,7 @@ document.addEventListener("DOMContentLoaded", function() {
styleSelect.value = localStorage.getItem(style_cookie);
}
- if (document.body.className == "threads") {
+ if (document.body.classList.contains("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");
@@ -250,13 +272,12 @@ document.addEventListener("DOMContentLoaded", function() {
if(localStorage.hasOwnProperty("hiddenposts"))
hiddenposts = localStorage.getItem("hiddenposts").split("!");
- var pps = document.getElementsByClassName("date");
- for(var i=0;i<pps.length;i++) {
- if(hiddenposts.includes(board+pps[i].dataset.unix)) {
- console.log(pps[i].dataset.unix);
- hidepost(pps[i].parentElement.parentElement);
+ for(var i=0;i<dt.length;i++) {
+ if(hiddenposts.includes(board+dt[i].dataset.unix)) {
+ console.log(dt[i].dataset.unix);
+ hidepost(dt[i].parentElement.parentElement);
}
- pps[i].parentElement.addEventListener("dblclick", togglepost);
+ dt[i].parentElement.addEventListener("dblclick", togglepost);
}
});
document.addEventListener("click", function(e) {