diff options
Diffstat (limited to 'static/js/weabotxt.js')
-rw-r--r-- | static/js/weabotxt.js | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/static/js/weabotxt.js b/static/js/weabotxt.js index 269168e..5cf205e 100644 --- a/static/js/weabotxt.js +++ b/static/js/weabotxt.js @@ -11,44 +11,6 @@ function set_stylesheet(styletitle) { localStorage.setItem(style_cookie,styletitle); } -function changeDate() { - var dts = document.getElementsByClassName("date"); - if (dts[0].dataset.unix) { - week = ["dom", "lun", "mar", "mie", "jue", "vie", "sab"]; - if (board == "world") week = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; - for(var d=0;d<dts.length;d++) { - dts[d].addEventListener('mouseover', function(e) { this.title = "Hace " + timeAgo(this.dataset.unix); }); - if (dts[d].textContent.includes("ID:")) var id = dts[d].textContent.split(" ")[1]; - dts[d].textContent = localTime(dts[d].dataset.unix, id); - } - } -} - -function timeAgo(timestamp) { - var time = Math.round(Date.now()/1000); - var el = time - timestamp; - if (el==0) return "un instante"; - else if (el==1) return "un segundo"; - else if (el<60) return el + " segundos"; - else if (el<120) return "un minuto"; - else if (el<3600) return Math.round(el/60) + " minutos"; - else if (el<7200) return "una hora"; - else if (el<86400) return Math.round(el/3600) + " horas"; - else if (el<172800) return "un día"; - else if (el<2628000) return Math.round(el/86400) + " días"; - else if (el<5256000) return "un mes"; - else if (el<31536000) return Math.round(el/2628000) + " meses"; - else if (el>31535999) return "más de un año"; -} - -function localTime(timestamp, id) { - id = id || 0; - var lcl = new Date(timestamp*1000); - lcl = ("0"+lcl.getDate()).slice(-2) + "/" + ("0" + (lcl.getMonth()+1)).slice(-2) + "/" + lcl.getFullYear().toString().slice(-2) + "(" + week[lcl.getDay()] + ")" + ("0"+lcl.getHours()).slice(-2) + ":" + ("0"+lcl.getMinutes()).slice(-2) + ":" + ("0"+lcl.getSeconds()).slice(-2) - if (id) lcl = lcl + " " + id; - return lcl; -} - /* 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*/) { @@ -248,8 +210,10 @@ document.addEventListener("DOMContentLoaded", function() { else weabot = {"name":null,"email":null,"password":null}; board = document.body.dataset.brd; - var where = document.getElementById(board); - if (where) where.className = "cur_brd"; + var b = document.getElementById("main_nav").getElementsByTagName("a"); + for(var i=0; i<b.length; i++) { + if (b[i].getAttribute("href") == "/"+board+"/") { b[i].className = "cur_brd"; break; } + } var forms = document.getElementsByTagName("form"); for(var i=0;i<forms.length;i++) { if(forms[i].id.startsWith("postform")) setInputs(forms[i].id); } @@ -260,9 +224,6 @@ document.addEventListener("DOMContentLoaded", function() { styleSelect.value = localStorage.getItem(style_cookie); } - if(localStorage.getItem("shobon_time") != "false") - changeDate(); - if (document.body.className == "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(); }); } |