From 18f60364b920e0ff33bc4b8e3135590effeaf173 Mon Sep 17 00:00:00 2001 From: Renard Date: Sun, 29 Mar 2020 18:47:51 -0300 Subject: Prettier para JS --- static/js/aquiencitas.js | 165 ++-- static/js/autorefresh.js | 263 ++++-- static/js/home.js | 144 +++- static/js/manage.js | 11 +- static/js/mobile.js | 370 +++++--- static/js/palette_selfy.js | 1992 ++++++++++++++++++++++++++------------------ static/js/shobon.js | 400 +++++---- static/js/weabot.js | 484 +++++++---- static/js/weabotxt.js | 353 +++++--- 9 files changed, 2639 insertions(+), 1543 deletions(-) diff --git a/static/js/aquiencitas.js b/static/js/aquiencitas.js index 0cf860f..4284f0a 100644 --- a/static/js/aquiencitas.js +++ b/static/js/aquiencitas.js @@ -4,41 +4,59 @@ var linki; var is_bbs; var plimit = 5; function getPostRange(t, n) { - var posts, replies, s, ss, ee, rev = false; + var posts, + replies, + s, + ss, + ee, + rev = false; posts = []; replies = t.getElementsByClassName("reply"); - s = n.split('-'); + s = n.split("-"); ss = parseInt(s[0]); ee = ss; - if(s.length == 2) ee = parseInt(s[1]); - if(ee ee) break; - if(num >= ss && num <= ee) { - if(rev) posts.unshift(replies[j]); + if (num > ee) break; + if (num >= ss && num <= ee) { + if (rev) posts.unshift(replies[j]); else posts.push(replies[j]); } } return posts; } -function findAncestor (el) { - while ((el = el.parentElement) && !el.className.startsWith("thread") && !el.className.startsWith("cont")); +function findAncestor(el) { + while ( + (el = el.parentElement) && + !el.className.startsWith("thread") && + !el.className.startsWith("cont") + ); return el; } function getPostDivs(e) { - if(is_bbs) { + if (is_bbs) { divs = []; t = findAncestor(e); - s = e.getAttribute('href').split('/'); - r = s[s.length-1]; - rs = r.split(','); + s = e.getAttribute("href").split("/"); + r = s[s.length - 1]; + rs = r.split(","); linki = 0; - for(i=0;i maxWidth) { width = maxWidth; } - - for(i=0;i>")) continue; - - if(localStorage.getItem("shobon_preview") != "false") { - q.addEventListener('mouseover', who_are_you_quoting, false); - q.addEventListener('mouseout', remove_quote_preview, false); + if (q.textContent.length < 3 || !q.textContent.startsWith(">>")) continue; + + if (localStorage.getItem("shobon_preview") != "false") { + q.addEventListener("mouseover", who_are_you_quoting, false); + q.addEventListener("mouseout", remove_quote_preview, false); } - - if(localStorage.getItem("shobon_backlink") != "false") { + + if (localStorage.getItem("shobon_backlink") != "false") { fill_links(q); } } } -/* if (document.body.className === "threadpage") { + /* if (document.body.className === "threadpage") { for (x = 0; x < replies.length; x++) { var q = replies[x].getElementsByTagName("a"); for(var j=0;j' + post.name + ' ' + post.tripcode + ''; - else s_name = '' + post.name + ''; + if (post.tripcode) + s_name = + '' + + post.name + + " " + + post.tripcode + + ""; + else + s_name = + '' + + post.name + + ""; } else { - if (post.tripcode) s_name = '' + post.name + ' ' + post.tripcode + ''; - else s_name = '' + post.name + ''; + if (post.tripcode) + s_name = + '' + + post.name + + " " + + post.tripcode + + ""; + else s_name = '' + post.name + ""; } if (serviceType == 2) { if (post.file) { - s_img = '
' + Math.round(post.file_size/1024) + 'KB ' + post.file.substring(post.file.lastIndexOf(".")+1, post.file.length).toUpperCase() + '
'; - } else s_img = ''; - if (post.IS_DELETED == 1) div.innerHTML = '

' + num + ' : Mensaje eliminado por el usuario.

'; - else if (post.IS_DELETED == 2) div.innerHTML = '

' + num + ' : Mensaje eliminado por miembro del staff.

'; - else - div.innerHTML = '

' + num + ' : ' + s_name + ' : ' + post.timestamp_formatted + ' rep del

' + s_img + '
' + post.message + '
'; + s_img = + '
' + + Math.round(post.file_size / 1024) + + "KB " + + post.file + .substring(post.file.lastIndexOf(".") + 1, post.file.length) + .toUpperCase() + + "
"; + } else s_img = ""; + if (post.IS_DELETED == 1) + div.innerHTML = + '

' + + num + + " : Mensaje eliminado por el usuario.

"; + else if (post.IS_DELETED == 2) + div.innerHTML = + '

' + + num + + " : Mensaje eliminado por miembro del staff.

"; + else + div.innerHTML = + '

' + + num + + " : " + + s_name + + ' : ' + + post.timestamp_formatted + + ' rep del

' + + s_img + + '
' + + post.message + + "
"; } else { if (post.file) { if (post.image_width != 0) { - s_img = '
' + post.file + '-(' + post.file_size+ ' B, ' + post.image_width + 'x' + post.image_height + ')
'; + s_img = + '
' + + post.file + + "-(" + + post.file_size + + " B, " + + post.image_width + + "x" + + post.image_height + + ")
"; } else { - s_img = '
' + post.file + '-(' + post.file_size+ ' B)
'; + s_img = + '
' + + post.file + + "-(" + + post.file_size + + " B)
"; } - s_img += '' + post.id + ''; - s_msg = '
' + post.message + '
'; + s_img += + '' +
+          post.id +
+          ''; + s_msg = + '
' + + post.message + + "
"; } else { - s_img = ''; - s_msg = '
' + post.message + '
'; + s_img = ""; + s_msg = "
" + post.message + "
"; } if (post.IS_DELETED == 0) { - div.innerHTML = '
' + (post.subject ? (' ' + post.subject + '') : '') + ' ' + s_name + ' ' + '' + post.timestamp_formatted + ' No.' + post.id + ' rep
' + s_img + s_msg + '
'; + div.innerHTML = + '
' + + (post.subject + ? ' ' + post.subject + "" + : "") + + " " + + s_name + + " " + + '' + + post.timestamp_formatted + + ' No.' + + post.id + + ' rep
' + + s_img + + s_msg + + "
"; } } thread_div.insertBefore(div, last_elem); - thread_div.setAttribute("data-length",num); - if (serviceType == 2) document.getElementsByTagName("h3")[0].getElementsByTagName("span")[0].innerText = "("+num+" respuestas)"; + thread_div.setAttribute("data-length", num); + if (serviceType == 2) + document + .getElementsByTagName("h3")[0] + .getElementsByTagName("span")[0].innerText = "(" + num + " respuestas)"; } if (posts.length > 0) { - if (!manual) - refreshMaxTime = 10; + if (!manual) refreshMaxTime = 10; if (!document.hasFocus()) - if (posts.length > 1) notif(thread_title, posts.length + ' nuevos mensajes'); - else notif(thread_title, 'Un nuevo mensaje'); + if (posts.length > 1) + notif(thread_title, posts.length + " nuevos mensajes"); + else notif(thread_title, "Un nuevo mensaje"); } else { - if (refreshMaxTime <= 60) - refreshMaxTime += 5; + if (refreshMaxTime <= 60) refreshMaxTime += 5; } thread_length = parseInt(total_replies) + 1; //document.getElementsByClassName("thread")[0].firstChild.children[0].innerHTML = "("+thread_length+")"; new_unread = thread_length - thread_first_length; - if (new_unread) - document.title = "(" + new_unread + ") " + thread_title; - else - document.title = thread_title; + if (new_unread) document.title = "(" + new_unread + ") " + thread_title; + else document.title = thread_title; } function notif(title, msg) { @@ -115,7 +272,7 @@ function counter() { loadJSON(); } else { refreshTime--; - document.getElementById("counter").innerHTML = (refreshTime + 1); + document.getElementById("counter").innerHTML = refreshTime + 1; } } @@ -123,7 +280,9 @@ function detectService() { if (document.body.classList.contains("threadpage")) { if (!document.getElementById("n")) return; thread_title = document.title; - thread_length = parseInt(document.getElementsByClassName("thread")[0].dataset.length); + thread_length = parseInt( + document.getElementsByClassName("thread")[0].dataset.length + ); thread_first_length = thread_length; replylist = document.getElementsByClassName("reply"); lastr = replylist[replylist.length - 1].textContent; @@ -158,7 +317,9 @@ function detectService() { } else if (document.body.className === "res") { serviceType = 3; thread_title = document.title; - thread_length = parseInt(document.getElementsByClassName("thread")[0].dataset.length); + thread_length = parseInt( + document.getElementsByClassName("thread")[0].dataset.length + ); thread_first_length = thread_length; replylist = document.getElementsByClassName("thread"); replylist += document.getElementsByClassName("reply"); @@ -208,15 +369,13 @@ function stopCounter(str) { function autoRefresh(e) { chk_snd = document.getElementById("autosound"); if (document.getElementById("autorefresh").checked) { - if (chk_snd) - chk_snd.disabled = false; + if (chk_snd) chk_snd.disabled = false; Notification.requestPermission(); lastTime = Math.floor(Date.now() / 1000); refreshTime = refreshMaxTime; startCounter(); } else { - if (chk_snd) - document.getElementById("autosound").disabled = true; + if (chk_snd) document.getElementById("autosound").disabled = true; stopCounter("OFF"); } } @@ -228,15 +387,14 @@ http_request.onreadystatechange = function() { if (serviceType == 2 || serviceType == 3) updateThread(jsonObj.posts, jsonObj.total_replies, jsonObj.time); lastTime = jsonObj.time; - if (chk.checked) - startCounter(); + if (chk.checked) startCounter(); } if (!chk.checked) { document.getElementById("counter").innerText = "OFF"; } manual = 0; } -} +}; document.addEventListener("DOMContentLoaded", function() { if (!detectService()) return; @@ -254,17 +412,14 @@ document.addEventListener("DOMContentLoaded", function() { window.addEventListener("unload", function() { if (!serviceType) return; - + chk = document.getElementById("autorefresh"); chk_snd = document.getElementById("autosound"); - if (chk.checked) - localStorage.setItem("autorefresh", true); - else - localStorage.removeItem("autorefresh"); + if (chk.checked) localStorage.setItem("autorefresh", true); + else localStorage.removeItem("autorefresh"); if (!chk_snd) return; if (!document.getElementById("autosound").checked) localStorage.setItem("mainpage_nosound", true); - else - localStorage.removeItem("mainpage_nosound"); -}); \ No newline at end of file + else localStorage.removeItem("mainpage_nosound"); +}); diff --git a/static/js/home.js b/static/js/home.js index 6c9e23a..0a90627 100644 --- a/static/js/home.js +++ b/static/js/home.js @@ -3,37 +3,43 @@ console.log("%c¡Es calidad BaI!", "font-size: 50px; font-weight: bold;"); function set_stylesheet(styletitle) { opcs.style = styletitle; parse(); - var links=document.getElementsByTagName("link"); - var found=false; - for(var i=0;i last_t) { - items[i].className += ' urgent'; - dates[i].innerHTML = '
' + dates[i].innerHTML; - } - opcs.last = Date.now() / 1000 | 0; + var items = document.getElementsByClassName("ni"); + var dates = document.getElementsByClassName("ni-d"); + for (var i = 0; i < items.length; i++) + if (parseInt(items[i].dataset.t) > last_t) { + items[i].className += " urgent"; + dates[i].innerHTML = + '
' + + dates[i].innerHTML; + } + opcs.last = (Date.now() / 1000) | 0; parse(); } @@ -48,7 +54,11 @@ var http_request = new XMLHttpRequest(); function loadJSON() { stopCounter("..."); - var data_file = "/cgi/api/lastage?time=" + lastTime + "&limit=" + document.getElementById("limit").value; + var data_file = + "/cgi/api/lastage?time=" + + lastTime + + "&limit=" + + document.getElementById("limit").value; http_request.open("GET", data_file, true); http_request.send(); } @@ -78,22 +88,42 @@ function updatePostList(threads, serverTime) { thread = threads[i]; if (thread.bumped >= lastTime) { unread[thread.id] = true; - news.push('- ' + thread.board_fulln + ': ' + thread.content); + news.push("- " + thread.board_fulln + ": " + thread.content); new_unread = true; } if (unread[thread.id]) html += ''; - html += '[' + thread.board_name + '] ' + thread.content + ' (' + thread.length + ')'; + html += + '[' + + thread.board_name + + '] ' + + thread.content + + ' (' + + thread.length + + ")"; if (unread[thread.id]) { - html += ''; + html += ""; newposts++; } } - if (newposts) newTitle = '(' + newposts + ') ' + newTitle; + if (newposts) newTitle = "(" + newposts + ") " + newTitle; if (new_unread) { document.getElementById("newposts").style = "color:red"; - notif('Bienvenido a Internet BBS/IB', 'Hay nuevos mensajes:\n' + news.join('\n')); + notif( + "Bienvenido a Internet BBS/IB", + "Hay nuevos mensajes:\n" + news.join("\n") + ); refreshMaxTime = 10; - if (document.getElementById('autosound').checked) { + if (document.getElementById("autosound").checked) { document.getElementById("machina").volume = 0.6; document.getElementById("machina").play(); } @@ -149,27 +179,49 @@ http_request.onreadystatechange = function() { if (chk.checked) startCounter(); } } -} +}; -function parse() { localStorage.setItem("home", JSON.stringify(opcs)); } +function parse() { + localStorage.setItem("home", JSON.stringify(opcs)); +} document.addEventListener("DOMContentLoaded", function() { - window.parent.document.title = document.getElementsByTagName("title")[0].textContent; + window.parent.document.title = document.getElementsByTagName( + "title" + )[0].textContent; - if (localStorage.hasOwnProperty("home")) opcs=JSON.parse(localStorage.getItem("home")); - else { opcs={"style":"IB","auto":false,"sound":false,"last":0}; parse(); } + if (localStorage.hasOwnProperty("home")) + opcs = JSON.parse(localStorage.getItem("home")); + else { + opcs = { style: "IB", auto: false, sound: false, last: 0 }; + parse(); + } set_stylesheet(opcs.style); - + var css = document.getElementById("change_style").getElementsByTagName("a"); - for(var j=0;j")+"\n"; sel="\n"+sel; } + if (sel) { + sel = sel.replace(/^/gm, ">") + "\n"; + sel = "\n" + sel; + } insert(">>" + parseInt(this.innerHTML, 10) + sel); } function insert(text) { - var textarea=document.forms.postform.message; - if(textarea) { - if(textarea.createTextRange && textarea.caretPos) { // IE - var caretPos=textarea.caretPos; - caretPos.text=caretPos.text.charAt(caretPos.text.length-1)==" "?text+" ":text; - } else if(textarea.setSelectionRange) { // Firefox - var start=textarea.selectionStart; - var end=textarea.selectionEnd; - textarea.value=textarea.value.substr(0,start)+text+textarea.value.substr(end); - textarea.setSelectionRange(start+text.length,start+text.length); - } else { - textarea.value+=text+" "; - } - textarea.focus(); - } + var textarea = document.forms.postform.message; + if (textarea) { + if (textarea.createTextRange && textarea.caretPos) { + // IE + var caretPos = textarea.caretPos; + caretPos.text = + caretPos.text.charAt(caretPos.text.length - 1) == " " + ? text + " " + : text; + } else if (textarea.setSelectionRange) { + // Firefox + var start = textarea.selectionStart; + var end = textarea.selectionEnd; + textarea.value = + textarea.value.substr(0, start) + text + textarea.value.substr(end); + textarea.setSelectionRange(start + text.length, start + text.length); + } else { + textarea.value += text + " "; + } + textarea.focus(); + } return false; } function getPassword() { if (weabot.password) return weabot.password; - var char="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - var pass=""; - for (var i=0;i<8;i++) { - var rnd = Math.floor(Math.random()*char.length); - pass += char.substring(rnd, rnd+1); - } + var char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + var pass = ""; + for (var i = 0; i < 8; i++) { + var rnd = Math.floor(Math.random() * char.length); + pass += char.substring(rnd, rnd + 1); + } console.log(weabot.password); - weabot.password = pass; + weabot.password = pass; localStorage.setItem("weabot", JSON.stringify(weabot)); - return(pass); + return pass; } function saveInputs(e) { var e = e || window.event; var form = e.target || e.srcElement; - if(typeof(form.fielda) !== "undefined") weabot.name = form.fielda.value; - if(typeof(form.fielda) !== "undefined") weabot.email = form.fieldb.value; + if (typeof form.fielda !== "undefined") weabot.name = form.fielda.value; + if (typeof form.fielda !== "undefined") weabot.email = form.fieldb.value; localStorage.setItem("weabot", JSON.stringify(weabot)); } function setInputs() { - with(document.getElementById("postform")) { - if(typeof(fielda) !== 'undefined' && !fielda.value && weabot.name) fielda.value = weabot.name; - if(typeof(fielda) !== 'undefined' && !fieldb.value && weabot.email) fieldb.value = weabot.email; - if(!password.value) password.value = getPassword(); + with (document.getElementById("postform")) { + if (typeof fielda !== "undefined" && !fielda.value && weabot.name) + fielda.value = weabot.name; + if (typeof fielda !== "undefined" && !fieldb.value && weabot.email) + fieldb.value = weabot.email; + if (!password.value) password.value = getPassword(); addEventListener("submit", saveInputs); } } @@ -84,12 +97,12 @@ function showMenu(e) { var num = parseInt(post.getElementsByClassName("num")[0].innerText, 10); } else { var id = post.getElementsByClassName("num")[0].innerText; - var num = ((post.className === "first") ? 1 : 0); + var num = post.className === "first" ? 1 : 0; } var menu = document.createElement("div"); menu.id = "mnu-list"; - menu.style.top = (e.pageY + 5) + "px"; - menu.style.left = (e.pageX + 5) + "px"; + menu.style.top = e.pageY + 5 + "px"; + menu.style.left = e.pageX + 5 + "px"; document.body.appendChild(menu); menu = document.getElementById("mnu-list"); var rep = document.createElement("a"); @@ -97,15 +110,24 @@ function showMenu(e) { rep.innerText = "Denunciar post"; rep.addEventListener("click", function(e) { var reason = prompt("Razón de denuncia:"); - if (reason === "") while(reason === "") reason = prompt("Error: Ingresa una razón."); + if (reason === "") + while (reason === "") reason = prompt("Error: Ingresa una razón."); if (reason) { var rep_req = new XMLHttpRequest(); - var report = "/cgi/report/" + brd + "/" + id + ((num) ? "/" + num : "") + "?reason=" + reason; + var report = + "/cgi/report/" + + brd + + "/" + + id + + (num ? "/" + num : "") + + "?reason=" + + reason; rep_req.open("GET", report, true); rep_req.send(); rep_req.onreadystatechange = function() { - if (rep_req.readyState == 4 && rep_req.status == 200) alert("Denuncia enviada."); - } + if (rep_req.readyState == 4 && rep_req.status == 200) + alert("Denuncia enviada."); + }; } }); menu.appendChild(rep); @@ -113,9 +135,17 @@ function showMenu(e) { del.href = "#"; del.innerText = "Eliminar post"; del.addEventListener("click", function(e) { - if(confirm("¿Seguro que deseas borrar el mensaje "+((num) ? num : id)+"?")) { + if ( + confirm("¿Seguro que deseas borrar el mensaje " + (num ? num : id) + "?") + ) { var del_req = new XMLHttpRequest(); - var del_form = "/cgi/api/delete?dir=" + brd + "&id=" + id + "&password=" + postform.password.value; + var del_form = + "/cgi/api/delete?dir=" + + brd + + "&id=" + + id + + "&password=" + + postform.password.value; del_req.open("GET", del_form, true); del_req.send(); del_req.onreadystatechange = function() { @@ -131,7 +161,7 @@ function showMenu(e) { } } else if (response.state == "failed") alert(response.message); } - } + }; } }); menu.appendChild(del); @@ -141,9 +171,22 @@ function showMenu(e) { dfile.href = "#"; dfile.innerText = "Eliminar archivo"; dfile.addEventListener("click", function(e) { - if(confirm("¿Seguro que deseas borrar el archivo del mensaje "+((num) ? num : id)+"?")) { + if ( + confirm( + "¿Seguro que deseas borrar el archivo del mensaje " + + (num ? num : id) + + "?" + ) + ) { var fdel_req = new XMLHttpRequest(); - var fdel_form = "/cgi/api/delete?dir=" + brd + "&id=" + id + "&password=" + postform.password.value + "&imageonly=true"; + var fdel_form = + "/cgi/api/delete?dir=" + + brd + + "&id=" + + id + + "&password=" + + postform.password.value + + "&imageonly=true"; fdel_req.open("GET", fdel_form, true); fdel_req.send(); fdel_req.onreadystatechange = function() { @@ -154,7 +197,7 @@ function showMenu(e) { post.removeChild(file); } else if (response.state == "failed") alert(response.message); } - } + }; } }); menu.appendChild(dfile); @@ -176,9 +219,16 @@ function closeMenu(e) { function searchSubjects() { var filter = document.getElementById("search").value.toLowerCase(); - var nodes = document.getElementsByClassName("list")[0].getElementsByTagName("a"); + var nodes = document + .getElementsByClassName("list")[0] + .getElementsByTagName("a"); for (i = 0; i < nodes.length; i++) { - if (nodes[i].innerHTML.toLowerCase().split(/<\/?br[^>]*>\s*/im)[0].includes(filter)) + if ( + nodes[i].innerHTML + .toLowerCase() + .split(/<\/?br[^>]*>\s*/im)[0] + .includes(filter) + ) nodes[i].removeAttribute("style"); else nodes[i].style.display = "none"; } @@ -188,7 +238,12 @@ function searchCatalog() { var filter = document.getElementById("catsearch").value.toLowerCase(); var nodes = document.getElementsByClassName("cat"); for (i = 0; i < nodes.length; i++) { - if (nodes[i].innerText.toLowerCase().substring(nodes[i].innerText.indexOf("R)")+2).includes(filter)) + if ( + nodes[i].innerText + .toLowerCase() + .substring(nodes[i].innerText.indexOf("R)") + 2) + .includes(filter) + ) nodes[i].removeAttribute("style"); else nodes[i].style.display = "none"; } @@ -221,7 +276,15 @@ function loadJSON() { } var data_file; if (serviceType) - data_file = "/cgi/api/thread?dir=" + postform.board.value + "&id=" + postform.parent.value + "&offset=" + thread_length + "&time=" + lastTime; + data_file = + "/cgi/api/thread?dir=" + + postform.board.value + + "&id=" + + postform.parent.value + + "&offset=" + + thread_length + + "&time=" + + lastTime; else return false; http_request.open("GET", data_file, true); http_request.send(); @@ -234,50 +297,114 @@ function updateThread(posts, total_replies, serverTime) { for (var i = 0; i < posts.length; i++) { post = posts[i]; brd = postform.board.value; - var div = document.createElement('div'); + var div = document.createElement("div"); div.className = "pst"; div.id = "p" + post.id; if (post.IS_DELETED == 0) { s_name = post.name; - if (post.tripcode) s_name += ' ' + post.tripcode; + if (post.tripcode) s_name += " " + post.tripcode; s_time = post.timestamp_formatted.replace(/\(.{1,3}\)/g, " "); if (post.file) - s_img = '
' + Math.round(post.file_size/1024) + 'KB ' + post.file.substring(post.file.lastIndexOf(".")+1, post.file.length).toUpperCase() + '
'; - else s_img = ''; + s_img = + '
' + + Math.round(post.file_size / 1024) + + "KB " + + post.file + .substring(post.file.lastIndexOf(".") + 1, post.file.length) + .toUpperCase() + + "
"; + else s_img = ""; } if (serviceType == 1) { var pad = "0000" + (thread_length + i + 1); - pad = pad.substr(pad.length-4); + pad = pad.substr(pad.length - 4); if (post.IS_DELETED == 0) - div.innerHTML = '

' + pad + ' ' + s_name + '

' + s_img + '
' + post.message + '

' + s_time + '|||

'; + div.innerHTML = + '

' + + pad + + " " + + s_name + + "

" + + s_img + + '
' + + post.message + + "

" + + s_time + + '|||

'; else if (post.IS_DELETED == 1) - div.innerHTML = '

' + pad + ' : Eliminado por el usuario.

'; + div.innerHTML = + '

' + + pad + + " : Eliminado por el usuario.

"; else - div.innerHTML = '

' + pad + ' : Eliminado por miembro del staff.

'; + div.innerHTML = + '

' + + pad + + " : Eliminado por miembro del staff.

"; } else { if (post.IS_DELETED == 0) { - div.innerHTML = '

' + s_name + ' ' + s_time + ' ' + post.id + '|||

' + s_img + '
' + post.message + '
'; - } else if (post.IS_DELETED == 1) { div.innerHTML = '

No.' + post.id + ' eliminado por el usuario.

'; } - else { div.innerHTML = '

No.' + post.id + ' eliminado por miembro del staff.

'; } + div.innerHTML = + "

" + + s_name + + " " + + s_time + + ' ' + + post.id + + '|||

' + + s_img + + '
' + + post.message + + "
"; + } else if (post.IS_DELETED == 1) { + div.innerHTML = + '

No.' + + post.id + + " eliminado por el usuario.

"; + } else { + div.innerHTML = + '

No.' + + post.id + + " eliminado por miembro del staff.

"; + } } div.getElementsByClassName("mnu")[0].addEventListener("click", showMenu); div.getElementsByClassName("num")[0].addEventListener("click", postClick); thread_div.insertBefore(div, last_elem); - document.getElementsByTagName("h1")[0].getElementsByTagName("span")[0].innerText = "(" + (thread_length + i + 1) + ")" + document + .getElementsByTagName("h1")[0] + .getElementsByTagName("span")[0].innerText = + "(" + (thread_length + i + 1) + ")"; } if (posts.length > 0) { if (!manual) refreshMaxTime = 10; if (!document.hasFocus()) - if (posts.length > 1) notif(thread_title, posts.length + ' nuevos mensajes'); - else notif(thread_title, 'Un nuevo mensaje'); - } else { if (refreshMaxTime <= 60) refreshMaxTime += 5; } + if (posts.length > 1) + notif(thread_title, posts.length + " nuevos mensajes"); + else notif(thread_title, "Un nuevo mensaje"); + } else { + if (refreshMaxTime <= 60) refreshMaxTime += 5; + } thread_length = parseInt(total_replies) + 1; new_unread = thread_length - thread_first_length; - if (new_unread) document.title = '(' + new_unread + ') ' + thread_title; + if (new_unread) document.title = "(" + new_unread + ") " + thread_title; else document.title = thread_title; } @@ -290,28 +417,50 @@ function counter() { if (refreshTime < 1) loadJSON(); else { refreshTime--; - document.getElementById("counter").innerHTML = (refreshTime + 1); + document.getElementById("counter").innerHTML = refreshTime + 1; } } function detectService() { if (document.getElementById("thread")) { - thread_title = document.getElementsByTagName("h1")[0].innerHTML.split(" \")[0] + " - " + document.title; - thread_length = parseInt(document.getElementsByTagName("h1")[0].getElementsByTagName("span")[0].innerText.slice(1, -1), 10); + thread_title = + document.getElementsByTagName("h1")[0].innerHTML.split(" ")[0] + + " - " + + document.title; + thread_length = parseInt( + document + .getElementsByTagName("h1")[0] + .getElementsByTagName("span")[0] + .innerText.slice(1, -1), + 10 + ); thread_first_length = thread_length; if (document.body.className === "txt") { serviceType = 1; replylist = document.getElementsByClassName("pst"); - thread_lastreply = parseInt(replylist[replylist.length - 1].getElementsByClassName("num")[0].innerText); + thread_lastreply = parseInt( + replylist[replylist.length - 1].getElementsByClassName("num")[0] + .innerText + ); if (thread_length == thread_lastreply) { serviceType = 1; - document.getElementById("n2").setAttribute("style", "border-top:1px solid #c6c7c8;border-left:1px solid #c6c7c8;display:inline-block;text-align:center;width:50%;"); + document + .getElementById("n2") + .setAttribute( + "style", + "border-top:1px solid #c6c7c8;border-left:1px solid #c6c7c8;display:inline-block;text-align:center;width:50%;" + ); return true; } else return false; } else if (document.body.className === "img") { serviceType = 2; document.getElementById("n").innerText = "Ver nuevos posts"; - document.getElementById("n2").setAttribute("style", "border-top:1px solid #333;border-left:1px solid #333;display:inline-block;text-align:center;width:50%;"); + document + .getElementById("n2") + .setAttribute( + "style", + "border-top:1px solid #333;border-left:1px solid #333;display:inline-block;text-align:center;width:50%;" + ); replylist = document.getElementsByClassName("first"); replylist += document.getElementsByClassName("pst"); return true; @@ -358,51 +507,78 @@ http_request.onreadystatechange = function() { } manual = 0; } -} +}; function sortList(type) { - for(var i=0;i"(‚^O) Ă // +// 艺 ">"(‚^O) Ă // // pbg̑I{^(type=radio)^O̒g -selfv[3] = 'style="border-width:0;" title="ftHg̃pbg">'; // ftHgF -selfv[4] = 'style="border-width:0;" title="̃pbggB\n`FbNĂƂɂɉƁA`FbNOA\nFz‚Aʓx+xpbgɁB(1Ԃ̐F{F)">'; // I - +selfv[3] = 'style="border-width:0;" title="ftHg̃pbg">'; // ftHgF +selfv[4] = + 'style="border-width:0;" title="̃pbggB\n`FbNĂƂɂɉƁA`FbNOA\nFz‚Aʓx+xpbgɁB(1Ԃ̐F{F)">'; // I // {^(type=button)^O̒g -selfv[5] = 'value="H" title="Fpbg (1Ԃ̐F{F)">'; // F -selfv[6] = 'value="S" title="ʓxpbg (1Ԃ̐F{F)">'; // ʓx -selfv[7] = 'value="B" title="xpbg (1Ԃ̐F{F)">\n'; // x -selfv[8] = 'value="o" title="ɍ̃pbgۑ">'; // Z[u -selfv[9] = 'value="x" title="̃pbgftHgɖ߂">
\n'; // ftHg - -selfv[10] = 'value="H+" title="pbgŜ̐F{">'; // F+ -selfv[11] = 'value="H-" title="pbgŜ̐F|">'; // F- -selfv[12] = 'value="S+" title="pbgŜ̍ʓx{">'; // ʓx+ -selfv[13] = 'value="S-" title="pbgŜ̍ʓx|">'; // ʓx- -selfv[14] = 'value="B+" title="pbgŜ̖x{">\n'; // x+ -selfv[15] = 'value="B-" title="pbgŜ̖x|">\n'; // x- -selfv[16] = 'value="RGB+" title="pbgŜRGB{">
\n'; // RGB+ -selfv[17] = 'value="RGB-" title="pbgŜRGB|">
\n'; // RGB- - +selfv[5] = 'value="H" title="Fpbg (1Ԃ̐F{F)">'; // F +selfv[6] = 'value="S" title="ʓxpbg (1Ԃ̐F{F)">'; // ʓx +selfv[7] = 'value="B" title="xpbg (1Ԃ̐F{F)">\n'; // x +selfv[8] = 'value="o" title="ɍ̃pbgۑ">'; // Z[u +selfv[9] = 'value="x" title="̃pbgftHgɖ߂">
\n'; // ftHg + +selfv[10] = 'value="H+" title="pbgŜ̐F{">'; // F+ +selfv[11] = 'value="H-" title="pbgŜ̐F|">'; // F- +selfv[12] = 'value="S+" title="pbgŜ̍ʓx{">'; // ʓx+ +selfv[13] = 'value="S-" title="pbgŜ̍ʓx|">'; // ʓx- +selfv[14] = 'value="B+" title="pbgŜ̖x{">\n'; // x+ +selfv[15] = 'value="B-" title="pbgŜ̖x|">\n'; // x- +selfv[16] = 'value="RGB+" title="pbgŜRGB{">
\n'; // RGB+ +selfv[17] = 'value="RGB-" title="pbgŜRGB|">
\n'; // RGB- // Of[V̂Ƃ -selfv[18] = 'style="border-width:0;" title="2_ɃOf[V (1Ԃ̐F14Ԃ̐F)" checked>2'; // 2_ -selfv[19] = 'style="border-width:0;" title="3_ɃOf[V (1ԁA8ԁA14Ԃ̐F)">3'; // 3_ -selfv[20] = 'style="border-width:0;" title="4_ɃOf[V (1A6A10A14Ԃ̐F)">4
\n'; // 4_ -selfv[21] = 'value="RGB" title="RGBŃOf[V">\n'; // RGB? -selfv[22] = 'value="+HSB" title="+HSBŃOf[V (F{)">\n'; // +HSB -selfv[23] = 'value="-HSB" title="-HSBŃOf[V (F|)">
\n'; // -HSB - +selfv[18] = + 'style="border-width:0;" title="2_ɃOf[V (1Ԃ̐F14Ԃ̐F)" checked>2'; // 2_ +selfv[19] = + 'style="border-width:0;" title="3_ɃOf[V (1ԁA8ԁA14Ԃ̐F)">3'; // 3_ +selfv[20] = + 'style="border-width:0;" title="4_ɃOf[V (1A6A10A14Ԃ̐F)">4
\n'; // 4_ +selfv[21] = 'value="RGB" title="RGBŃOf[V">\n'; // RGB? +selfv[22] = 'value="+HSB" title="+HSBŃOf[V (F{)">\n'; // +HSB +selfv[23] = 'value="-HSB" title="-HSBŃOf[V (F|)">
\n'; // -HSB // ljE폜 -selfv[24] = 'value="+" title="pbglj܂">'; // lj -selfv[25] = 'value="-" title="I𒆂̃pbg폜܂">\n'; // 폜 - +selfv[24] = 'value="+" title="pbglj܂">'; // lj +selfv[25] = 'value="-" title="I𒆂̃pbg폜܂">\n'; // 폜 // Z[uEI[gZ[u -selfv[26] = 'checked title="Ƀ`FbN‚ĂƁAFύXƂA\n@ŕۑpbgɃpbgZ[u܂B\nۑKp̂́A\n@`FbNĂpbg瑼̃pbgɈړƂA\n@`FbNĂpbgH/S/B{^ƂA\n@2‚̂ƂłBTv̐Fς܂B\nAɃ`FbNĂȂĂA\n@蓮ŃZ[u{^΁Apbgɕۑ܂B">'; // Z[u -selfv[27] = 'value="O" title="̑Ŝ̃pbgNbL[ɕۑ">
\n'; // Z[u - +selfv[26] = + 'checked title="Ƀ`FbN‚ĂƁAFύXƂA\n@ŕۑpbgɃpbgZ[u܂B\nۑKp̂́A\n@`FbNĂpbg瑼̃pbgɈړƂA\n@`FbNĂpbgH/S/B{^ƂA\n@2‚̂ƂłBTv̐Fς܂B\nAɃ`FbNĂȂĂA\n@蓮ŃZ[u{^΁Apbgɕۑ܂B">'; // Z[u +selfv[27] = 'value="O" title="̑Ŝ̃pbgNbL[ɕۑ">
\n'; // Z[u // ftHg̃pbg F360ɂ邩Aʓx++x-- ɂ邩 -selfv[28] = 'style="border-width:0;" title="ftHg̃pbǵAFŏz‚">Ho'; // H -selfv[29] = 'style="border-width:0;" title="ftHg̃pbǵAʓx{Ax|ŃXg">+S-B'; // +S-B -selfv[30] = 'value="X" title="Ŝ̃pbgftHgɖ߂">
\n'; // ftHg - +selfv[28] = + 'style="border-width:0;" title="ftHg̃pbǵAFŏz‚">Ho'; // H +selfv[29] = + 'style="border-width:0;" title="ftHg̃pbǵAʓx{Ax|ŃXg">+S-B'; // +S-B +selfv[30] = 'value="X" title="Ŝ̃pbgftHgɖ߂">
\n'; // ftHg // UPLOAD / DOWNLOAD -selfv[31] = 'value="" size=8 title="pbgf[^B\nEAbv[hƂ́Aɓ\tĂB\nE_E[hƂ́AɃf[^o͂܂B\n@ [J̃eLXgɂłۑĂB\npbgf[^́A\n pals = new Array(\'#FFFFFF\',\'#B47575\\n#888888\\n...\');\n@̂悤ɁAJS̔z`ŏ܂B">\n'; // -selfv[32] = 'value="" title="pbgf[^Abv[h">'; // -selfv[33] = 'value="" title="Ƀpbgf[^_E[h">
\n'; // - +selfv[31] = + "value=\"\" size=8 title=\"pbgf[^B\nEAbv[hƂ́Aɓ\tĂB\nE_E[hƂ́AɃf[^o͂܂B\n@ [J̃eLXgɂłۑĂB\npbgf[^́A\n pals = new Array('#FFFFFF','#B47575\\n#888888\\n...');\n@̂悤ɁAJS̔z`ŏ܂B\">\n"; // +selfv[32] = 'value="" title="pbgf[^Abv[h">'; // +selfv[33] = 'value="" title="Ƀpbgf[^_E[h">
\n'; // // ̃pbge[u͂łA\[XƂ^OƂ (form^O͏_) // tH[n܂ -selfytag[0] = '
\n\n
\n'; +selfytag[0] = + '
\n\n
\n'; // tH[̊_1 (•ʂ̃pbg ` Ŝ HSBARGB +- Ƃ) selfytag[1] = '
\n'; // tH[̊_2 (Ŝ HSBARGB +- Ƃ ` Of[V) -selfytag[2] = '
\n
\nGradation'; +selfytag[2] = + '
\n
\nGradation'; // tH[̊_3 (Of[V ` pbg̒ljE폜{^) -selfytag[3] = '
\n
\nPalette'; +selfytag[3] = + '
\n
\nPalette'; // tH[̊_4 (pbg̒ljE폜{^ ` Z[u{^) -selfytag[4] = '\nSave'; +selfytag[4] = "\nSave"; // tH[̊_5 (Z[u{^ ` Default H++/+S-B ǂ炩) -selfytag[5] = '
\n
\nDefault'; +selfytag[5] = + '
\n
\nDefault'; // tH[̊_6 (Default H++/+S-B ǂ炩 ` pbg̃Abv/_E[h) -selfytag[6] = '
\n
\nUpdata '; +selfytag[6] = + '
\n
\nUpdata '; // tH[I -selfytag[7] = '
\n
\n
\n'; +selfytag[7] = "
\n\n
\n"; //ݒ肨 ------------------------------------------------------ - // l (ƂŎgl) var d = document; -var pon,pno; // radio`FbNH / `FbNpbgNO. -var qon,qno,qmo; // buttonvbVH / vbVpbgNO. -var pals = new Array(); // color-palette -var inp = '=g && r>=b){ - max=r; - }else if(g>=b){ - max=g; - }else{ - max=b; - } - - // min - if(r<=g && r<=b){ - min=r; - }else if(g<=b){ - min=g; - }else{ - min=b; - } - - // 0,0,0 - if(max<=0){ return(new Array(0,0,0)); } - - // difference - dif=max-min; - - //Hue: - if(max>min){ - if(g==max){ - h=(b-r)/dif*60+120; - }else if(b==max){ - h=(r-g)/dif*60+240; - }else if(b>g){ - h=(g-b)/dif*60+360; - }else{ - h=(g-b)/dif*60; - } - if(h<0){ - h=h+360; - } - }else{ h=0; } - h*=255/360; - - //Saturation: - s=(dif/max)*255; - - //Value: - v=max; - - return(new Array(h,s,v)); +function RGBtoHSB(r, g, b) { + var max, min, dif, h, s, v; + + // max + if (r >= g && r >= b) { + max = r; + } else if (g >= b) { + max = g; + } else { + max = b; + } + + // min + if (r <= g && r <= b) { + min = r; + } else if (g <= b) { + min = g; + } else { + min = b; + } + + // 0,0,0 + if (max <= 0) { + return new Array(0, 0, 0); + } + + // difference + dif = max - min; + + //Hue: + if (max > min) { + if (g == max) { + h = ((b - r) / dif) * 60 + 120; + } else if (b == max) { + h = ((r - g) / dif) * 60 + 240; + } else if (b > g) { + h = ((g - b) / dif) * 60 + 360; + } else { + h = ((g - b) / dif) * 60; + } + if (h < 0) { + h = h + 360; + } + } else { + h = 0; + } + h *= 255 / 360; + + //Saturation: + s = (dif / max) * 255; + + //Value: + v = max; + + return new Array(h, s, v); } - // RGB16RGB10 \L. l 000000`ffffff -function to10rgb(str){ - var ns = new Array(); - str = str.replace(/[^0-9a-fA-F]/g,''); - for(var i=0; i<=2; i++){ - ns[i] = str.substr(i*2,2); - if(!ns[i]){ ns[i]='00'; } - ns[i] = Number(parseInt(ns[i],16).toString(10)); - } - return(ns); +function to10rgb(str) { + var ns = new Array(); + str = str.replace(/[^0-9a-fA-F]/g, ""); + for (var i = 0; i <= 2; i++) { + ns[i] = str.substr(i * 2, 2); + if (!ns[i]) { + ns[i] = "00"; + } + ns[i] = Number(parseInt(ns[i], 16).toString(10)); + } + return ns; } - // 1016i@ -function format16(n){ - n = Number(n).toString(16); - if(n.length<2){ n='0'+n; } - return(n); +function format16(n) { + n = Number(n).toString(16); + if (n.length < 2) { + n = "0" + n; + } + return n; } - - - // ------------------------------------------------------------------------- // pbg ( q=1:Avbgpbgɏo͂Ȃ. lst=1:ŏ̂Ƃ -function rady(p,q,lst){ - var d = document; - var df = d.forms.palepale; - - // ftHgpbg - if(!p&&p!=0){ pon=0; pno=''; d.paintbbs.setColors(pbase); return; } - - var ps = pals[p].split('\n'); - var n = pnum; - if(!q && df.num.value){ n = Number(df.num.value); } - if(!q && pon==1 && pno!=p){ poncheck(); } - - // ĂȂ炷Ԃ - if((pon!=1 || pno!=p) && ps.length==14){ - if(!q){ pon=1; pno=p; } - if(q!=1 && pals[p]){ d.paintbbs.setColors(pals[p]); } return; - } - - // checkĂȂ - if(pon==1 && pno==p){ - var pget = String(d.paintbbs.getColors()); -// if(pget==pals[p]){ return; } - var cs = pget.split('\n'); - ps[0] = cs[0]; ps[1] = ''; - } - // ĂȂ - var cs = new Array(); - - var psy=0; // H/ +S-B - psy = check_h_sb(lst); - - if(psy==1){ cs = rh_list(p,n); }// HXg - else{ cs = sb_list(p,n); } // +S-B Xg - - if(q){ // ݒ莞 - pals[p] = String(cs.join('\n')); - } - if(q!=1){ // - if(pon==1 && pno==p){ checkout(); } - else{ pon=1; pno=p; } -// pals[p] = String(cs.join('\n')); - d.paintbbs.setColors(String(cs.join('\n'))); - } +function rady(p, q, lst) { + var d = document; + var df = d.forms.palepale; + + // ftHgpbg + if (!p && p != 0) { + pon = 0; + pno = ""; + d.paintbbs.setColors(pbase); + return; + } + + var ps = pals[p].split("\n"); + var n = pnum; + if (!q && df.num.value) { + n = Number(df.num.value); + } + if (!q && pon == 1 && pno != p) { + poncheck(); + } + + // ĂȂ炷Ԃ + if ((pon != 1 || pno != p) && ps.length == 14) { + if (!q) { + pon = 1; + pno = p; + } + if (q != 1 && pals[p]) { + d.paintbbs.setColors(pals[p]); + } + return; + } + + // checkĂȂ + if (pon == 1 && pno == p) { + var pget = String(d.paintbbs.getColors()); + // if(pget==pals[p]){ return; } + var cs = pget.split("\n"); + ps[0] = cs[0]; + ps[1] = ""; + } + // ĂȂ + var cs = new Array(); + + var psy = 0; // H/ +S-B + psy = check_h_sb(lst); + + if (psy == 1) { + cs = rh_list(p, n); + } // HXg + else { + cs = sb_list(p, n); + } // +S-B Xg + + if (q) { + // ݒ莞 + pals[p] = String(cs.join("\n")); + } + if (q != 1) { + // + if (pon == 1 && pno == p) { + checkout(); + } else { + pon = 1; + pno = p; + } + // pals[p] = String(cs.join('\n')); + d.paintbbs.setColors(String(cs.join("\n"))); + } } - // HXg -function rh_list(p,n){ - var ps = pals[p].split('\n'); - var rgb = to10rgb(ps[0]); //RGB - var hsv = RGBtoHSB(rgb[0],rgb[1],rgb[2]); //HSB - var cs = new Array(ps[0],ps[1]); - if(!cs[0]){ cs[0]='#ffffff'; } - if(hsv[1]!=0 && !cs[13]){ cs[13]='#ffffff'; } - - for (var i=1; i<13; i++){ - if(ps[i] && (pon!=1 || pno!=p)){ cs[i]=ps[i]; continue; } // - var x,y,z; - if(hsv[1]==0){ // - x = hsv[0]; - y = 0; - if(i%2==0){ z = 255-i*n; }else{ z = 0+(i-1)*n; } - }else if(i>=12){ - x = hsv[0]; - y = 0; - z = 255-hsv[1]; - }else{ - x = hsv[0] + i*255/12; - y = hsv[1]; - z = hsv[2]; - } - while(x<0){ x+=255; } if(y<0){ y=0; } if(z<0){ z=0; } //0 - while(x>255){ x-=255; } if(y>255){ y=255; } if(z>255){ z=255; } //255 -// for (var j=0; j<=2; j++){ hsv[j] = Math.round(hsv[j]); } - rgb = HSBtoRGB(x,y,z); - for (var j=0; j<=2; j++){ rgb[j] = Math.round(rgb[j]); } - cs[i] = '#'+format16(rgb[0])+format16(rgb[1])+format16(rgb[2]); - } - return(cs); +function rh_list(p, n) { + var ps = pals[p].split("\n"); + var rgb = to10rgb(ps[0]); //RGB + var hsv = RGBtoHSB(rgb[0], rgb[1], rgb[2]); //HSB + var cs = new Array(ps[0], ps[1]); + if (!cs[0]) { + cs[0] = "#ffffff"; + } + if (hsv[1] != 0 && !cs[13]) { + cs[13] = "#ffffff"; + } + + for (var i = 1; i < 13; i++) { + if (ps[i] && (pon != 1 || pno != p)) { + cs[i] = ps[i]; + continue; + } // + var x, y, z; + if (hsv[1] == 0) { + // + x = hsv[0]; + y = 0; + if (i % 2 == 0) { + z = 255 - i * n; + } else { + z = 0 + (i - 1) * n; + } + } else if (i >= 12) { + x = hsv[0]; + y = 0; + z = 255 - hsv[1]; + } else { + x = hsv[0] + (i * 255) / 12; + y = hsv[1]; + z = hsv[2]; + } + while (x < 0) { + x += 255; + } + if (y < 0) { + y = 0; + } + if (z < 0) { + z = 0; + } //0 + while (x > 255) { + x -= 255; + } + if (y > 255) { + y = 255; + } + if (z > 255) { + z = 255; + } //255 + // for (var j=0; j<=2; j++){ hsv[j] = Math.round(hsv[j]); } + rgb = HSBtoRGB(x, y, z); + for (var j = 0; j <= 2; j++) { + rgb[j] = Math.round(rgb[j]); + } + cs[i] = "#" + format16(rgb[0]) + format16(rgb[1]) + format16(rgb[2]); + } + return cs; } - // +S-B Xg -function sb_list(p,n){ - var ps = pals[p].split('\n'); - var rgb = to10rgb(ps[0]); //RGB - var hsv = RGBtoHSB(rgb[0],rgb[1],rgb[2]); //HSB - var cs = new Array(ps[0],ps[1]); - if(!cs[0]){ cs[0]='#ffffff'; } - if(hsv[1]==0 && !cs[1]){ cs[1]='#000000'; } - else if(!cs[1]){ cs[1]='#ffffff'; } - - for (var i=2; i<14; i++){ - if(ps[i] && (pon!=1 || pno!=p)){ cs[i]=ps[i]; continue; } // - var y,z; - if(hsv[1]==0){ // - y = 0; - if(i%2==0){ z = 255-i*n; }else{ z = 0+(i-1)*n; } - }else{ - if(i%2==0){ // - y = hsv[1]+i*n; - z = hsv[2]; - }else{ //E - y = hsv[1]+(i-1)*n; - z = hsv[2]-(i-1)*n; - } - } - while(z<0){ z+=255; } while(y<0){ y+=255; } //0 - while(z>255){ z-=255; } while(y>255){ y-=255; } //255 -// for (var j=0; j<=2; j++){ hsv[j] = Math.round(hsv[j]); } - rgb = HSBtoRGB(hsv[0],y,z); - for (var j=0; j<=2; j++){ rgb[j] = Math.round(rgb[j]); } - cs[i] = '#'+format16(rgb[0])+format16(rgb[1])+format16(rgb[2]); - } - return(cs); +function sb_list(p, n) { + var ps = pals[p].split("\n"); + var rgb = to10rgb(ps[0]); //RGB + var hsv = RGBtoHSB(rgb[0], rgb[1], rgb[2]); //HSB + var cs = new Array(ps[0], ps[1]); + if (!cs[0]) { + cs[0] = "#ffffff"; + } + if (hsv[1] == 0 && !cs[1]) { + cs[1] = "#000000"; + } else if (!cs[1]) { + cs[1] = "#ffffff"; + } + + for (var i = 2; i < 14; i++) { + if (ps[i] && (pon != 1 || pno != p)) { + cs[i] = ps[i]; + continue; + } // + var y, z; + if (hsv[1] == 0) { + // + y = 0; + if (i % 2 == 0) { + z = 255 - i * n; + } else { + z = 0 + (i - 1) * n; + } + } else { + if (i % 2 == 0) { + // + y = hsv[1] + i * n; + z = hsv[2]; + } else { + //E + y = hsv[1] + (i - 1) * n; + z = hsv[2] - (i - 1) * n; + } + } + while (z < 0) { + z += 255; + } + while (y < 0) { + y += 255; + } //0 + while (z > 255) { + z -= 255; + } + while (y > 255) { + y -= 255; + } //255 + // for (var j=0; j<=2; j++){ hsv[j] = Math.round(hsv[j]); } + rgb = HSBtoRGB(hsv[0], y, z); + for (var j = 0; j <= 2; j++) { + rgb[j] = Math.round(rgb[j]); + } + cs[i] = "#" + format16(rgb[0]) + format16(rgb[1]) + format16(rgb[2]); + } + return cs; } - // •ʂH/S/BXgAbv -function onplus(p,m){ - var d = document; - var df = d.forms.palepale; - var n = Number(df.num.value); //+- - if(pon==1 && pno==p){ poncheck(); } - - // ÂƂ - if(m>0 && n*(qon+1)>38){ qon=0; } - if(qno==p && qmo==m && qon>=1){ qon++; n*=(qon+1)/2; } - else{ qno=p; qmo=m; qon=1; } - - var ps = pals[p].split('\n'); - var rgb = to10rgb(ps[0]); //RGB - var hsv = RGBtoHSB(rgb[0],rgb[1],rgb[2]); //HSB - var cs = new Array(); - if(m==2){ n*=-1; } - for (var i=0; i<14; i++){ - var z; - if(m==0){ z = hsv[m]+((i%2)*2-1)*Math.round(Math.floor(i/2)*(n)); } - else{ z = hsv[m]+i*n; } - while(z<0){ z+=255; } //0 - while(z>255){ z-=255; } //255 -// for (var j=0; j<=2; j++){ hsv[j] = Math.round(hsv[j]); } - if(m==1){ rgb = HSBtoRGB(hsv[0],z,hsv[2]); } //HSB - else if(m==2){ rgb = HSBtoRGB(hsv[0],hsv[1],z); } - else{ rgb = HSBtoRGB(z,hsv[1],hsv[2]); } //HSB - for (var j=0; j<=2; j++){ rgb[j] = Math.round(rgb[j]); } - cs[i] = '#'+format16(rgb[0])+format16(rgb[1])+format16(rgb[2]); - } - checkout(1); - d.paintbbs.setColors(String(cs.join('\n'))); +function onplus(p, m) { + var d = document; + var df = d.forms.palepale; + var n = Number(df.num.value); //+- + if (pon == 1 && pno == p) { + poncheck(); + } + + // ÂƂ + if (m > 0 && n * (qon + 1) > 38) { + qon = 0; + } + if (qno == p && qmo == m && qon >= 1) { + qon++; + n *= (qon + 1) / 2; + } else { + qno = p; + qmo = m; + qon = 1; + } + + var ps = pals[p].split("\n"); + var rgb = to10rgb(ps[0]); //RGB + var hsv = RGBtoHSB(rgb[0], rgb[1], rgb[2]); //HSB + var cs = new Array(); + if (m == 2) { + n *= -1; + } + for (var i = 0; i < 14; i++) { + var z; + if (m == 0) { + z = hsv[m] + ((i % 2) * 2 - 1) * Math.round(Math.floor(i / 2) * n); + } else { + z = hsv[m] + i * n; + } + while (z < 0) { + z += 255; + } //0 + while (z > 255) { + z -= 255; + } //255 + // for (var j=0; j<=2; j++){ hsv[j] = Math.round(hsv[j]); } + if (m == 1) { + rgb = HSBtoRGB(hsv[0], z, hsv[2]); + } //HSB + else if (m == 2) { + rgb = HSBtoRGB(hsv[0], hsv[1], z); + } else { + rgb = HSBtoRGB(z, hsv[1], hsv[2]); + } //HSB + for (var j = 0; j <= 2; j++) { + rgb[j] = Math.round(rgb[j]); + } + cs[i] = "#" + format16(rgb[0]) + format16(rgb[1]) + format16(rgb[2]); + } + checkout(1); + d.paintbbs.setColors(String(cs.join("\n"))); } - // ŜH/S/BvX}CiX -function alplus(m,n){ - var d = document; - var cs = String(d.paintbbs.getColors()).split('\n'); - n *= Number(d.forms.palepale.num.value); //+- - poncheck(); - - for (var i=0; i0 && hsv[2]>=255){ - hsv[1] -= n; - if(hsv[1]<0){ hsv[1]=0; }else if(hsv[1]>255){ hsv[1]=255; } //0 or 255 - } - hsv[m] += n; - //0 255 - if(m==0){ - if(hsv[0]<0){ hsv[0]+=255; }else if(hsv[0]>255){ hsv[0]-=255; } - }else{ - if(hsv[m]<0){ hsv[m]=0; }else if(hsv[m]>255){ hsv[m]=255; } - } -// for (var j=0; j<=2; j++){ hsv[j] = Math.round(hsv[j]); } - rgb = HSBtoRGB(hsv[0],hsv[1],hsv[2]); //HSB - for (var j=0; j<=2; j++){ rgb[j] = Math.round(rgb[j]); } - cs[i] = '#'+format16(rgb[0])+format16(rgb[1])+format16(rgb[2]); - } - checkout(); - d.paintbbs.setColors(String(cs.join('\n'))); +function alplus(m, n) { + var d = document; + var cs = String(d.paintbbs.getColors()).split("\n"); + n *= Number(d.forms.palepale.num.value); //+- + poncheck(); + + for (var i = 0; i < cs.length; i++) { + var rgb = to10rgb(cs[i]); //RGB + var hsv = RGBtoHSB(rgb[0], rgb[1], rgb[2]); //HSB + //x255̂Ƃʓx + if (m == 2 && n > 0 && hsv[2] >= 255) { + hsv[1] -= n; + if (hsv[1] < 0) { + hsv[1] = 0; + } else if (hsv[1] > 255) { + hsv[1] = 255; + } //0 or 255 + } + hsv[m] += n; + //0 255 + if (m == 0) { + if (hsv[0] < 0) { + hsv[0] += 255; + } else if (hsv[0] > 255) { + hsv[0] -= 255; + } + } else { + if (hsv[m] < 0) { + hsv[m] = 0; + } else if (hsv[m] > 255) { + hsv[m] = 255; + } + } + // for (var j=0; j<=2; j++){ hsv[j] = Math.round(hsv[j]); } + rgb = HSBtoRGB(hsv[0], hsv[1], hsv[2]); //HSB + for (var j = 0; j <= 2; j++) { + rgb[j] = Math.round(rgb[j]); + } + cs[i] = "#" + format16(rgb[0]) + format16(rgb[1]) + format16(rgb[2]); + } + checkout(); + d.paintbbs.setColors(String(cs.join("\n"))); } - // ŜRGBvX}CiX -function alrgb(n){ - var d = document; - var cs = String(d.paintbbs.getColors()).split('\n'); - n *= Number(d.forms.palepale.num.value); //+- - poncheck(); - - for (var i=0; i255){ rgb[j]=255; } //255 - } - cs[i] = '#'+format16(rgb[0])+format16(rgb[1])+format16(rgb[2]); - } - checkout(); - d.paintbbs.setColors(String(cs.join('\n'))); +function alrgb(n) { + var d = document; + var cs = String(d.paintbbs.getColors()).split("\n"); + n *= Number(d.forms.palepale.num.value); //+- + poncheck(); + + for (var i = 0; i < cs.length; i++) { + var rgb = to10rgb(cs[i]); //RGB + for (var j = 0; j <= 2; j++) { + rgb[j] += n; + rgb[j] = Math.round(rgb[j]); + if (rgb[j] < 0) { + rgb[j] = 0; + } //0 + if (rgb[j] > 255) { + rgb[j] = 255; + } //255 + } + cs[i] = "#" + format16(rgb[0]) + format16(rgb[1]) + format16(rgb[2]); + } + checkout(); + d.paintbbs.setColors(String(cs.join("\n"))); } - // Of[V -function grady(m){ - var d = document; - var df = d.forms.palepale; - var n = 2; - if(df.gradc){ - for(var j=0; jm*hsvq[j]){ sa = Math.abs(sa) - 255/(q-p); } - hsv[0] = hsvp[0] + m*Math.abs(sa)*(k-p); - if(hsv[0]<0){ hsv[0]+=255; }else if(hsv[0]>255){ hsv[0]-=255; } - }else{ // S,B - hsv[j] = hsvp[j] - sa*(k-p); - if(hsv[j]<0){ hsv[j]=0; }else if(hsv[j]>255){ hsv[j]=255; } - } - } - rgb = HSBtoRGB(hsv[0],hsv[1],hsv[2]); //HSB - for (var j=0; j<=2; j++){ rgb[j] = Math.round(rgb[j]); } - // RGB - }else{ - for (var j=0; j<=2; j++){ // RGB - var sa = (rgbp[j]-rgbq[j])/(q-p); - rgb[j] = Math.round(rgbp[j] - sa*(k-p)); - if(rgb[j]<0){ rgb[j]=0; }else if(rgb[j]>255){ rgb[j]=255; } // - } - } - cs[k] = '#'+format16(rgb[0])+format16(rgb[1])+format16(rgb[2]); - } - } - cs[0]=cs[1]; cs[1]='#ffffff'; - checkout(); - d.paintbbs.setColors(String(cs.join('\n'))); +function grady(m) { + var d = document; + var df = d.forms.palepale; + var n = 2; + if (df.gradc) { + for (var j = 0; j < df.gradc.length; j++) { + if (df.gradc[j].checked == true) { + n = Number(df.gradc[j].value); + break; + } + } + } + var cs = String(d.paintbbs.getColors()).split("\n"); + var gs = new Array(1, 13); + if (n == 3) { + gs = new Array(1, 7, 13); + } else if (n == 4) { + gs = new Array(1, 5, 9, 13); + } + poncheck(); + cs[1] = cs[0]; + + // 2`4F + for (var i = 0; i < gs.length - 1; i++) { + var p = gs[i]; + var q = gs[i + 1]; + var rgbp = to10rgb(cs[p]); //RGB + var rgbq = to10rgb(cs[q]); //RGB2 + // HSB + var hsvp = new Array(); + var hsvq = new Array(); + if (m == 1 || m == -1) { + hsvp = RGBtoHSB(rgbp[0], rgbp[1], rgbp[2]); //HSB + hsvq = RGBtoHSB(rgbq[0], rgbq[1], rgbq[2]); //HSB + } + // pbg̐F + for (var k = p + 1; k < q; k++) { + var rgb = new Array(); + // HSB + if (m == 1 || m == -1) { + var hsv = new Array(); + for (var j = 0; j <= 2; j++) { + // RGB + var sa = (hsvp[j] - hsvq[j]) / (q - p); + if (j == 0) { + // H + if (m * hsvp[j] > m * hsvq[j]) { + sa = Math.abs(sa) - 255 / (q - p); + } + hsv[0] = hsvp[0] + m * Math.abs(sa) * (k - p); + if (hsv[0] < 0) { + hsv[0] += 255; + } else if (hsv[0] > 255) { + hsv[0] -= 255; + } + } else { + // S,B + hsv[j] = hsvp[j] - sa * (k - p); + if (hsv[j] < 0) { + hsv[j] = 0; + } else if (hsv[j] > 255) { + hsv[j] = 255; + } + } + } + rgb = HSBtoRGB(hsv[0], hsv[1], hsv[2]); //HSB + for (var j = 0; j <= 2; j++) { + rgb[j] = Math.round(rgb[j]); + } + // RGB + } else { + for (var j = 0; j <= 2; j++) { + // RGB + var sa = (rgbp[j] - rgbq[j]) / (q - p); + rgb[j] = Math.round(rgbp[j] - sa * (k - p)); + if (rgb[j] < 0) { + rgb[j] = 0; + } else if (rgb[j] > 255) { + rgb[j] = 255; + } // + } + } + cs[k] = "#" + format16(rgb[0]) + format16(rgb[1]) + format16(rgb[2]); + } + } + cs[0] = cs[1]; + cs[1] = "#ffffff"; + checkout(); + d.paintbbs.setColors(String(cs.join("\n"))); } - // ------------------------------------------------------------------------- // pbg̃TvJ[ -function csamp(p,pz,lst){ - var ss=''; - var ps = pz.split('\n'); - var slong = sams.length; - var psy = check_h_sb(lst); if(psy==1){ slong = samx.length; } - // color-sample - for (var i=0; i'+selfv[1]+''; - } - return ss; +function csamp(p, pz, lst) { + var ss = ""; + var ps = pz.split("\n"); + var slong = sams.length; + var psy = check_h_sb(lst); + if (psy == 1) { + slong = samx.length; + } + // color-sample + for (var i = 0; i < slong; i++) { + // color-title + var k, + cl = "", + rgb = "", + hsv = "", + ctl = ""; + if (psy == 1) { + k = samx[i]; + } else { + k = sams[i]; + } + if (ps[k]) { + rgb = to10rgb(ps[k]); //RGB + hsv = RGBtoHSB(rgb[0], rgb[1], rgb[2]); //HSB + for (var j = 0; j <= 2; j++) { + hsv[j] = Math.round(hsv[j]); + } + ctl = "HSB: " + hsv[0] + "," + hsv[1] + "," + hsv[2] + "\n"; + ctl += + "RGB: " + rgb[0] + "," + rgb[1] + "," + rgb[2] + "\nRGB16: " + ps[k]; + } + if (selfv[2]) cl = selfv[2].replace(/\$FONT/i, ps[k]); + if (selfv[1]) + ss += + '' + + selfv[1] + + ""; + } + return ss; } - // pbg̃Xg -function palette_list(lst){ - var d = document; - var ds = ''; - for (var p=0; p'+samw+''; - if(selfv[5]) ds+=inp+'onclick="onplus('+p+',0)" '+selfv[5]; - if(selfv[6]) ds+=inp+'onclick="onplus('+p+',1)" '+selfv[6]; - if(selfv[7]) ds+=inp+'onclick="onplus('+p+',2)" '+selfv[7]; - if(selfv[8]) ds+=inp+'onclick="savy('+p+')" '+selfv[8]; - if(selfv[9]) ds+=inp+'onclick="defy('+p+')" '+selfv[9]; - } - return ds; +function palette_list(lst) { + var d = document; + var ds = ""; + for (var p = 0; p < pals.length; p++) { + if (!pals[p]) { + continue; + } + var samw = csamp(p, pals[p], lst); //Tv + + // element + if (selfv[4]) + ds += + inr + + 'name="rad" value="' + + p + + '" onclick="rady(' + + p + + ')" ' + + selfv[4] + + samw + + "\n"; + // ds+=''+samw+''; + if (selfv[5]) ds += inp + 'onclick="onplus(' + p + ',0)" ' + selfv[5]; + if (selfv[6]) ds += inp + 'onclick="onplus(' + p + ',1)" ' + selfv[6]; + if (selfv[7]) ds += inp + 'onclick="onplus(' + p + ',2)" ' + selfv[7]; + if (selfv[8]) ds += inp + 'onclick="savy(' + p + ')" ' + selfv[8]; + if (selfv[9]) ds += inp + 'onclick="defy(' + p + ')" ' + selfv[9]; + } + return ds; } - // `FbN‚AtHgJ[̃TvύX -function checkin(p,not){ - qno=''; qmo=''; qon=0; - if(!pals[p]){ return; } - var d = document; - // font-color - var ps = pals[p].split('\n'); - var slong = sams.length; - var psy = check_h_sb(); if(psy==1){ slong = samx.length; } - // color-sample - for (var i=0; i=plong){ - var k=0; - var pds = new Array(); pds = pals; - pals = new Array(); - for(var j=0; j= plong) { + var k = 0; + var pds = new Array(); + pds = pals; + pals = new Array(); + for (var j = 0; j < pds.length; j++) { + if (p != j && pds[j]) { + pals[k] = pds[j]; + k++; + } + } + } + + if (brwz == 1 && d.all("palelist").innerHTML) { + d.all("palelist").innerHTML = palette_list(); + } else if (brwz == 2 && d.getElementById("palelist").innerHTML) { + d.getElementById("palelist").innerHTML = palette_list(); + } + checkout(); } - // pbgftHg -function def_list(){ - var okd = confirm("Ŝ̃pbgftHgɖ߂܂B\n낵łH"); - if(!okd){ return; } - var d = document; - var df = d.forms.palepale; - pals = new Array(); - var psy = 0; - var plong = pdefs.length; - if(check_h_sb()==1){ psy=1; plong = pdefx.length; } - for (var p=0; p0){ n = Math.floor(m/10 + n)*10; } - if(n<0){ n=0; }else if(n<5){ n=5; }else if(n>100){ n=100; } - df.tone.value = n; - tone_sel(n); +function tone_plus(n) { + var df = document.forms.palepale; + var m = Number(df.tone.value); + if (m > 0) { + n = Math.floor(m / 10 + n) * 10; + } + if (n < 0) { + n = 0; + } else if (n < 5) { + n = 5; + } else if (n > 100) { + n = 100; + } + df.tone.value = n; + tone_sel(n); } - // g[ZNg -function tone_sel(t){ - var dp=document.paintbbs; - t = Number(t); - if(t==0){ dp.getInfo().m.iTT = 0; } - else{ dp.getInfo().m.iTT = Math.floor(t/10)+1; } +function tone_sel(t) { + var dp = document.paintbbs; + t = Number(t); + if (t == 0) { + dp.getInfo().m.iTT = 0; + } else { + dp.getInfo().m.iTT = Math.floor(t / 10) + 1; + } } - // ------------------------------------------------------------------------- // document.write -function palette_selfy(){ - var d = document; - var df = document.forms.palepale; - var pzs=palette_selfy.arguments; //pbgw肪Ƃ - - // browzer - if(brwz!=1 && brwz!=2){ return; } - - // pbgƃpbgNbL[ - var plong = pdefs.length; - if(psx==1){ plong = pdefx.length; } - for (var p=0; p=1){ var ok=0; //H - for (var q=0; q +-'); - d.write(''); - d.write(inp+'value="-" onclick="num_plus(-1)">\n'); - } - // pbgXg - if(pdefs||pdefx) d.write('
\n'+palette_list(1)+'
\n'); - - // Ŝ HSBARGB +- - if(selfytag[1]) d.write(selfytag[1]); - if(selfv[10]) d.write(inp+'onclick="alplus(0,1)" ' +selfv[10]); - if(selfv[12]) d.write(inp+'onclick="alplus(1,1)" ' +selfv[12]); - if(selfv[14]) d.write(inp+'onclick="alplus(2,1)" ' +selfv[14]); - if(selfv[16]) d.write(inp+'onclick="alrgb(1)" ' +selfv[16]); - if(selfv[11]) d.write(inp+'onclick="alplus(0,-1)" '+selfv[11]); - if(selfv[13]) d.write(inp+'onclick="alplus(1,-1)" '+selfv[13]); - if(selfv[15]) d.write(inp+'onclick="alplus(2,-1)" '+selfv[15]); - if(selfv[17]) d.write(inp+'onclick="alrgb(-1)" ' +selfv[17]); - - // g[ZNg - if(selfv[0]){ - d.write('Tone '); - d.write(inp+'value="+" onclick="tone_plus(1)">'); - d.write(inp+'value="-" onclick="tone_plus(-1)">\n'); - } - - // GRADATION - if(selfytag[2]) d.write(selfytag[2]); - if(selfv[18]) d.write(inr+'name="gradc" value="2" '+selfv[18]); //18 - if(selfv[19]) d.write(inr+'name="gradc" value="3" '+selfv[19]); //19 - if(selfv[20]) d.write(inr+'name="gradc" value="4" '+selfv[20]); //20 - if(selfv[21]) d.write(inp+'onclick="grady(0)" ' +selfv[21]); //21 - if(selfv[22]) d.write(inp+'onclick="grady(1)" ' +selfv[22]); //22 - if(selfv[23]) d.write(inp+'onclick="grady(-1)" ' +selfv[23]); //23 - - // ljE폜 - if(selfytag[3]) d.write(selfytag[3]); - if(selfv[24]) d.write(inp+'onclick="plusy()" ' +selfv[24]); //24 - if(selfv[25]) d.write(inp+'onclick="minsy()" ' +selfv[25]); //25 - - // Z[uEI[gZ[u - if(selfytag[4]) d.write(selfytag[4]); - if(selfv[26]) d.write('= 1) { + var ok = 0; //H + for (var q = 0; q < pzs.length; q++) { + if (p == pzs[q]) { + ok = 1; + break; + } + } + if (ok != 1) { + pals[p] = ""; + } + } + } + pcookget(); // cookie-get + psx_ch[psx] = "checked "; + for (var p = 0; p < pals.length; p++) { + if (pals[p]) { + rady(p, 1, 1); + } + } + + // basic + d.write(selfytag[0]); + if (selfv[3]) + d.write(inr + 'name="rad" value="-1" onclick="rady()" ' + selfv[3]); + if (pbase) d.write(csamp(-1, pbase, 1)); + + // +-鐔 + if (selfv[0]) { + d.write("\n +-"); + d.write(''); + d.write(inp + 'value="-" onclick="num_plus(-1)">\n'); + } + // pbgXg + if (pdefs || pdefx) + d.write('
\n' + palette_list(1) + "
\n"); + + // Ŝ HSBARGB +- + if (selfytag[1]) d.write(selfytag[1]); + if (selfv[10]) d.write(inp + 'onclick="alplus(0,1)" ' + selfv[10]); + if (selfv[12]) d.write(inp + 'onclick="alplus(1,1)" ' + selfv[12]); + if (selfv[14]) d.write(inp + 'onclick="alplus(2,1)" ' + selfv[14]); + if (selfv[16]) d.write(inp + 'onclick="alrgb(1)" ' + selfv[16]); + if (selfv[11]) d.write(inp + 'onclick="alplus(0,-1)" ' + selfv[11]); + if (selfv[13]) d.write(inp + 'onclick="alplus(1,-1)" ' + selfv[13]); + if (selfv[15]) d.write(inp + 'onclick="alplus(2,-1)" ' + selfv[15]); + if (selfv[17]) d.write(inp + 'onclick="alrgb(-1)" ' + selfv[17]); + + // g[ZNg + if (selfv[0]) { + d.write('Tone "); + d.write(inp + 'value="+" onclick="tone_plus(1)">'); + d.write(inp + 'value="-" onclick="tone_plus(-1)">\n'); + } + + // GRADATION + if (selfytag[2]) d.write(selfytag[2]); + if (selfv[18]) d.write(inr + 'name="gradc" value="2" ' + selfv[18]); //18 + if (selfv[19]) d.write(inr + 'name="gradc" value="3" ' + selfv[19]); //19 + if (selfv[20]) d.write(inr + 'name="gradc" value="4" ' + selfv[20]); //20 + if (selfv[21]) d.write(inp + 'onclick="grady(0)" ' + selfv[21]); //21 + if (selfv[22]) d.write(inp + 'onclick="grady(1)" ' + selfv[22]); //22 + if (selfv[23]) d.write(inp + 'onclick="grady(-1)" ' + selfv[23]); //23 + + // ljE폜 + if (selfytag[3]) d.write(selfytag[3]); + if (selfv[24]) d.write(inp + 'onclick="plusy()" ' + selfv[24]); //24 + if (selfv[25]) d.write(inp + 'onclick="minsy()" ' + selfv[25]); //25 + + // Z[uEI[gZ[u + if (selfytag[4]) d.write(selfytag[4]); + if (selfv[26]) + d.write('Nuevo!
"; } } // ocultar mensajes que coinciden con lista negra - if(are_filters) { + if (are_filters) { checkBlackList(reply); } // reemplazar ISO 3166-1 alpha-2 por nombres completos - if (localStorage.getItem("shobon_country") == "true" && boardName == "world") { - replaceCountryName(reply) + if ( + localStorage.getItem("shobon_country") == "true" && + boardName == "world" + ) { + replaceCountryName(reply); } // colorear IDs - if(localStorage.getItem("shobon_ids") != "false") { + if (localStorage.getItem("shobon_ids") != "false") { paintIds(reply); } // insertar imágenes - if(localStorage.getItem("shobon_embedimg") == "true") { + if (localStorage.getItem("shobon_embedimg") == "true") { embedImg(reply); } } @@ -114,24 +128,31 @@ function shobon() { btnNew.dataset.id = boardName + "_" + threadId; btnNew.dataset.last = lastReplyN; btnNew.textContent = "Marcar como leído"; - btnNew.setAttribute("style", "font-weight:bold; background:#81a2be; padding:5px; border-radius:5px; float:right; margin-bottom:10px;"); - btnNew.onclick = function(){ + btnNew.setAttribute( + "style", + "font-weight:bold; background:#81a2be; padding:5px; border-radius:5px; float:right; margin-bottom:10px;" + ); + btnNew.onclick = function() { localStorage.setItem(this.dataset.id, this.dataset.last); this.hidden = true; }; thread.getElementsByClassName("threadlinks")[0].appendChild(btnNew); } - } if (newRepliesCounter > 0 && !inThread) { var banner = document.createElement("span"); - banner.onclick = function() { this.hidden = true; }; - banner.setAttribute("style", "font-weight:bold; background:#8c9440; padding:8px; border-radius:30px; float:right; position:fixed; bottom:10px; right:10px"); + banner.onclick = function() { + this.hidden = true; + }; + banner.setAttribute( + "style", + "font-weight:bold; background:#8c9440; padding:8px; border-radius:30px; float:right; position:fixed; bottom:10px; right:10px" + ); banner.textContent = "Nuevas respuestas: " + newRepliesCounter; document.body.appendChild(banner); } - if(localStorage.getItem("shobon_newposts") == "true" && inThread) { + if (localStorage.getItem("shobon_newposts") == "true" && inThread) { localStorage.setItem(boardName + "_" + threadId, lastReplyN); } } @@ -146,11 +167,11 @@ function createCheckbox(name, label, def) { chk.id = name; chk.onchange = on_checked; lbl.appendChild(chk); - lbl.insertAdjacentHTML("beforeend", " "+label+" "); + lbl.insertAdjacentHTML("beforeend", " " + label + " "); var checked = localStorage.getItem(name); - if(checked !== null) { - chk.checked = (checked == "true"); + if (checked !== null) { + chk.checked = checked == "true"; } else { chk.checked = def; } @@ -177,32 +198,48 @@ function createTh(label, w) { return th; } function timeAgo(timestamp) { - var time = Math.round(Date.now()/1000); + 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"; + 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) + 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; } function loadFilters() { var filters = JSON.parse(localStorage.getItem("shobon_filters")); - if(filters) { + if (filters) { are_filters = true; hide_word = new Set(filters.word); hide_name = new Set(filters.name); @@ -211,9 +248,9 @@ function loadFilters() { } function saveFilters() { var filters = { - "word": Array.from(hide_word), - "name": Array.from(hide_name), - "id": Array.from(hide_id) + word: Array.from(hide_word), + name: Array.from(hide_name), + id: Array.from(hide_id) }; localStorage.setItem("shobon_filters", JSON.stringify(filters)); } @@ -221,7 +258,7 @@ function deleteFilter(e) { var tr = this.parentElement.parentElement; var name = tr.dataset.name; var type = tr.dataset.type; - switch(type) { + switch (type) { case "word": hide_word.delete(name); break; @@ -238,11 +275,11 @@ function deleteFilter(e) { function addFilter(e) { var name = document.getElementById("txt_filter").value; var type = document.getElementById("lst_type").value; - if(!name) { + if (!name) { return; } - switch(type) { + switch (type) { case "word": hide_word.add(name); break; @@ -259,7 +296,7 @@ function addFilter(e) { } function addToFilterTable(name, type) { - var dict = {"word": "Palabra", "name": "Nombre/Tripcode", "id": "ID"}; + var dict = { word: "Palabra", name: "Nombre/Tripcode", id: "ID" }; var table = document.getElementById("tbl_filters"); var td_type = document.createElement("td"); @@ -282,28 +319,50 @@ function shobonSettings(e) { e.preventDefault(); var titlebox = document.getElementById("titlebox"); - + var box = document.getElementById("settings"); - if(box) { - box.hidden = !box.hidden; + if (box) { + box.hidden = !box.hidden; } else { - box = document.createElement("div"); - box.id = "settings"; - box.className = "innerbox"; - box.style.textAlign = "center"; - - var p = document.createElement("div"); - p.appendChild(createCheckbox("shobon_on", "Activar extensión", true)); - p.appendChild(createCheckbox("shobon_navbar", "Fijar barra superior", false)); - p.appendChild(createCheckbox("shobon_ids", "Colorear IDs", true)); - p.appendChild(createCheckbox("shobon_embedimg", "Insertar imágenes miniatura", false)); - p.appendChild(createCheckbox("shobon_newposts", "Destacar mensajes nuevos", false)); - p.appendChild(createCheckbox("shobon_country", "Reemplazar códigos de país por nombres", false)); - p.appendChild(createCheckbox("shobon_time", "Convertir fechas a hora local", true)); - p.appendChild(createCheckbox("shobon_backlink", "Mostrar quién ha citado un post", true)); - p.appendChild(createCheckbox("shobon_preview", "Previsualizar citas", true)); - p.appendChild(createCheckbox("shobon_usefilters", "Activar filtros", false)); - /*var a = document.createElement("a"); + box = document.createElement("div"); + box.id = "settings"; + box.className = "innerbox"; + box.style.textAlign = "center"; + + var p = document.createElement("div"); + p.appendChild( + createCheckbox("shobon_on", "Activar extensión", true) + ); + p.appendChild( + createCheckbox("shobon_navbar", "Fijar barra superior", false) + ); + p.appendChild(createCheckbox("shobon_ids", "Colorear IDs", true)); + p.appendChild( + createCheckbox("shobon_embedimg", "Insertar imágenes miniatura", false) + ); + p.appendChild( + createCheckbox("shobon_newposts", "Destacar mensajes nuevos", false) + ); + p.appendChild( + createCheckbox( + "shobon_country", + "Reemplazar códigos de país por nombres", + false + ) + ); + p.appendChild( + createCheckbox("shobon_time", "Convertir fechas a hora local", true) + ); + p.appendChild( + createCheckbox("shobon_backlink", "Mostrar quién ha citado un post", true) + ); + p.appendChild( + createCheckbox("shobon_preview", "Previsualizar citas", true) + ); + p.appendChild( + createCheckbox("shobon_usefilters", "Activar filtros", false) + ); + /*var a = document.createElement("a"); a.href = "#"; a.textContent = "[Editar filtros]"; a.addEventListener("click", function() { @@ -311,66 +370,70 @@ function shobonSettings(e) { x.hidden = !x.hidden; }); p.appendChild(a);*/ - box.appendChild(p); - - var title2 = document.createElement("h6"); - title2.textContent = "Filtros"; - title2.style.fontSize = "18px"; - title2.style.margin = "0.5em 0"; - box.appendChild(title2); - - box.appendChild(document.createTextNode("Filtrar mensajes por: ")); - - var lst_type = document.createElement("select"); - lst_type.id = "lst_type"; - lst_type.appendChild(createOption("word", "Palabra")); - lst_type.appendChild(createOption("name", "Nombre/Tripcode")); - lst_type.appendChild(createOption("id", "ID")); - box.appendChild(lst_type); - - var txt_filter = document.createElement("input"); - txt_filter.id = "txt_filter"; - txt_filter.type = "text"; - box.appendChild(txt_filter); - - box.appendChild(createButton("Agregar", addFilter)); - - var tbl_filters = document.createElement("table"); - tbl_filters.id = "tbl_filters"; - tbl_filters.border = "1"; - tbl_filters.style.margin = "0 auto"; - var row = document.createElement("tr"); - row.appendChild(createTh("Tipo", 150)); - row.appendChild(createTh("Filtro", 300)); - row.appendChild(createTh("", 75)); - tbl_filters.appendChild(row); - box.appendChild(tbl_filters); - - var msg = document.createElement("a"); - msg.style.display = "block"; - msg.href = "#"; - msg.textContent = "Actualizar página para ver cambios"; - msg.style.marginTop = "1em"; - msg.addEventListener("click", function() { location.reload(); }); - box.appendChild(msg); - - titlebox.appendChild(box); - - var i; - hide_word.forEach(v => { - addToFilterTable(v, "word") - }); - hide_name.forEach(v => { - addToFilterTable(v, "name") - }); - hide_id.forEach(v => { - addToFilterTable(v, "id") - }); + box.appendChild(p); + + var title2 = document.createElement("h6"); + title2.textContent = "Filtros"; + title2.style.fontSize = "18px"; + title2.style.margin = "0.5em 0"; + box.appendChild(title2); + + box.appendChild(document.createTextNode("Filtrar mensajes por: ")); + + var lst_type = document.createElement("select"); + lst_type.id = "lst_type"; + lst_type.appendChild(createOption("word", "Palabra")); + lst_type.appendChild(createOption("name", "Nombre/Tripcode")); + lst_type.appendChild(createOption("id", "ID")); + box.appendChild(lst_type); + + var txt_filter = document.createElement("input"); + txt_filter.id = "txt_filter"; + txt_filter.type = "text"; + box.appendChild(txt_filter); + + box.appendChild(createButton("Agregar", addFilter)); + + var tbl_filters = document.createElement("table"); + tbl_filters.id = "tbl_filters"; + tbl_filters.border = "1"; + tbl_filters.style.margin = "0 auto"; + var row = document.createElement("tr"); + row.appendChild(createTh("Tipo", 150)); + row.appendChild(createTh("Filtro", 300)); + row.appendChild(createTh("", 75)); + tbl_filters.appendChild(row); + box.appendChild(tbl_filters); + + var msg = document.createElement("a"); + msg.style.display = "block"; + msg.href = "#"; + msg.textContent = "Actualizar página para ver cambios"; + msg.style.marginTop = "1em"; + msg.addEventListener("click", function() { + location.reload(); + }); + box.appendChild(msg); + + titlebox.appendChild(box); + + var i; + hide_word.forEach(v => { + addToFilterTable(v, "word"); + }); + hide_name.forEach(v => { + addToFilterTable(v, "name"); + }); + hide_id.forEach(v => { + addToFilterTable(v, "id"); + }); } } function replaceCountryName(reply) { - var country = JSON.parse('{"AF":"Afghanistan","AX":"A£land Islands","AL":"Albania","DZ":"Algeria","AS":"American Samoa","AD":"Andorra","AO":"Angola","AI":"Anguilla","AQ":"Antarctica","AG":"Antigua and Barbuda","AR":"Argentina","AM":"Armenia","AW":"Aruba","AU":"Australia","AT":"Austria","AZ":"Azerbaijan","BS":"Bahamas","BH":"Bahrain","BD":"Bangladesh","BB":"Barbados","BY":"Belarus","BE":"Belgium","BZ":"Belize","BJ":"Benin","BM":"Bermuda","BT":"Bhutan","BO":"Bolivia (Plurinational State of)","BQ":"Bonaire, Sint Eustatius and Saba","BA":"Bosnia and Herzegovina","BW":"Botswana","BV":"Bouvet Island","BR":"Brazil","IO":"British Indian Ocean Territory","BN":"Brunei Darussalam","BG":"Bulgaria","BF":"Burkina Faso","BI":"Burundi","KH":"Cambodia","CM":"Cameroon","CA":"Canada","CV":"Cabo Verde","KY":"Cayman Islands","CF":"Central African Republic","TD":"Chad","CL":"Chile","CN":"China","CX":"Christmas Island","CC":"Cocos (Keeling) Islands","CO":"Colombia","KM":"Comoros","CG":"Congo","CD":"Congo (Democratic Republic of the)","CK":"Cook Islands","CR":"Costa Rica","CI":"CAŒte d\'Ivoire","HR":"Croatia","CU":"Cuba","CW":"CuraAXao","CY":"Cyprus","CZ":"Czech Republic","DK":"Denmark","DJ":"Djibouti","DM":"Dominica","DO":"Dominican Republic","EC":"Ecuador","EG":"Egypt","SV":"El Salvador","GQ":"Equatorial Guinea","ER":"Eritrea","EE":"Estonia","ET":"Ethiopia","FK":"Falkland Islands (Malvinas)","FO":"Faroe Islands","FJ":"Fiji","FI":"Finland","FR":"France","GF":"French Guiana","PF":"French Polynesia","TF":"French Southern Territories","GA":"Gabon","GM":"Gambia","GE":"Georgia","DE":"Germany","GH":"Ghana","GI":"Gibraltar","GR":"Greece","GL":"Greenland","GD":"Grenada","GP":"Guadeloupe","GU":"Guam","GT":"Guatemala","GG":"Guernsey","GN":"Guinea","GW":"Guinea-Bissau","GY":"Guyana","HT":"Haiti","HM":"Heard Island and McDonald Islands","VA":"Holy See","HN":"Honduras","HK":"Hong Kong","HU":"Hungary","IS":"Iceland","IN":"India","ID":"Indonesia","IR":"Iran (Islamic Republic of)","IQ":"Iraq","IE":"Ireland","IM":"Isle of Man","IL":"Israel","IT":"Italy","JM":"Jamaica","JP":"Japan","JE":"Jersey","JO":"Jordan","KZ":"Kazakhstan","KE":"Kenya","KI":"Kiribati","KP":"Korea (Democratic People\'s Republic of)","KR":"Korea (Republic of)","KW":"Kuwait","KG":"Kyrgyzstan","LA":"Lao People\'s Democratic Republic","LV":"Latvia","LB":"Lebanon","LS":"Lesotho","LR":"Liberia","LY":"Libya","LI":"Liechtenstein","LT":"Lithuania","LU":"Luxembourg","MO":"Macao","MK":"Macedonia (the former Yugoslav Republic of)","MG":"Madagascar","MW":"Malawi","MY":"Malaysia","MV":"Maldives","ML":"Mali","MT":"Malta","MH":"Marshall Islands","MQ":"Martinique","MR":"Mauritania","MU":"Mauritius","YT":"Mayotte","MX":"Mexico","FM":"Micronesia (Federated States of)","MD":"Moldova (Republic of)","MC":"Monaco","MN":"Mongolia","ME":"Montenegro","MS":"Montserrat","MA":"Morocco","MZ":"Mozambique","MM":"Myanmar","NA":"Namibia","NR":"Nauru","NP":"Nepal","NL":"Netherlands","NC":"New Caledonia","NZ":"New Zealand","NI":"Nicaragua","NE":"Niger","NG":"Nigeria","NU":"Niue","NF":"Norfolk Island","MP":"Northern Mariana Islands","NO":"Norway","OM":"Oman","PK":"Pakistan","PW":"Palau","PS":"Palestine, State of","PA":"Panama","PG":"Papua New Guinea","PY":"Paraguay","PE":"Peru","PH":"Philippines","PN":"Pitcairn","PL":"Poland","PT":"Portugal","PR":"Puerto Rico","QA":"Qatar","RE":"RAcunion","RO":"Romania","RU":"Russian Federation","RW":"Rwanda","BL":"Saint BarthAclemy","SH":"Saint Helena, Ascension and Tristan da Cunha","KN":"Saint Kitts and Nevis","LC":"Saint Lucia","MF":"Saint Martin (French part)","PM":"Saint Pierre and Miquelon","VC":"Saint Vincent and the Grenadines","WS":"Samoa","SM":"San Marino","ST":"Sao Tome and Principe","SA":"Saudi Arabia","SN":"Senegal","RS":"Serbia","SC":"Seychelles","SL":"Sierra Leone","SG":"Singapore","SX":"Sint Maarten (Dutch part)","SK":"Slovakia","SI":"Slovenia","SB":"Solomon Islands","SO":"Somalia","ZA":"South Africa","GS":"South Georgia and the South Sandwich Islands","SS":"South Sudan","ES":"Spain","LK":"Sri Lanka","SD":"Sudan","SR":"Suriname","SJ":"Svalbard and Jan Mayen","SZ":"Swaziland","SE":"Sweden","CH":"Switzerland","SY":"Syrian Arab Republic","TW":"Taiwan, Province of China","TJ":"Tajikistan","TZ":"Tanzania, United Republic of","TH":"Thailand","TL":"Timor-Leste","TG":"Togo","TK":"Tokelau","TO":"Tonga","TT":"Trinidad and Tobago","TN":"Tunisia","TR":"Turkey","TM":"Turkmenistan","TC":"Turks and Caicos Islands","TV":"Tuvalu","UG":"Uganda","UA":"Ukraine","AE":"United Arab Emirates","GB":"United Kingdom of Great Britain and Northern Ireland","US":"United States of America","UM":"United States Minor Outlying Islands","UY":"Uruguay","UZ":"Uzbekistan","VU":"Vanuatu","VE":"Venezuela (Bolivarian Republic of)","VN":"Viet Nam","VG":"Virgin Islands (British)","VI":"Virgin Islands (U.S.)","WF":"Wallis and Futuna","EH":"Western Sahara","YE":"Yemen","ZM":"Zambia","ZW":"Zimbabwe"}'); + var country = JSON.parse( + '{"AF":"Afghanistan","AX":"A£land Islands","AL":"Albania","DZ":"Algeria","AS":"American Samoa","AD":"Andorra","AO":"Angola","AI":"Anguilla","AQ":"Antarctica","AG":"Antigua and Barbuda","AR":"Argentina","AM":"Armenia","AW":"Aruba","AU":"Australia","AT":"Austria","AZ":"Azerbaijan","BS":"Bahamas","BH":"Bahrain","BD":"Bangladesh","BB":"Barbados","BY":"Belarus","BE":"Belgium","BZ":"Belize","BJ":"Benin","BM":"Bermuda","BT":"Bhutan","BO":"Bolivia (Plurinational State of)","BQ":"Bonaire, Sint Eustatius and Saba","BA":"Bosnia and Herzegovina","BW":"Botswana","BV":"Bouvet Island","BR":"Brazil","IO":"British Indian Ocean Territory","BN":"Brunei Darussalam","BG":"Bulgaria","BF":"Burkina Faso","BI":"Burundi","KH":"Cambodia","CM":"Cameroon","CA":"Canada","CV":"Cabo Verde","KY":"Cayman Islands","CF":"Central African Republic","TD":"Chad","CL":"Chile","CN":"China","CX":"Christmas Island","CC":"Cocos (Keeling) Islands","CO":"Colombia","KM":"Comoros","CG":"Congo","CD":"Congo (Democratic Republic of the)","CK":"Cook Islands","CR":"Costa Rica","CI":"CAŒte d\'Ivoire","HR":"Croatia","CU":"Cuba","CW":"CuraAXao","CY":"Cyprus","CZ":"Czech Republic","DK":"Denmark","DJ":"Djibouti","DM":"Dominica","DO":"Dominican Republic","EC":"Ecuador","EG":"Egypt","SV":"El Salvador","GQ":"Equatorial Guinea","ER":"Eritrea","EE":"Estonia","ET":"Ethiopia","FK":"Falkland Islands (Malvinas)","FO":"Faroe Islands","FJ":"Fiji","FI":"Finland","FR":"France","GF":"French Guiana","PF":"French Polynesia","TF":"French Southern Territories","GA":"Gabon","GM":"Gambia","GE":"Georgia","DE":"Germany","GH":"Ghana","GI":"Gibraltar","GR":"Greece","GL":"Greenland","GD":"Grenada","GP":"Guadeloupe","GU":"Guam","GT":"Guatemala","GG":"Guernsey","GN":"Guinea","GW":"Guinea-Bissau","GY":"Guyana","HT":"Haiti","HM":"Heard Island and McDonald Islands","VA":"Holy See","HN":"Honduras","HK":"Hong Kong","HU":"Hungary","IS":"Iceland","IN":"India","ID":"Indonesia","IR":"Iran (Islamic Republic of)","IQ":"Iraq","IE":"Ireland","IM":"Isle of Man","IL":"Israel","IT":"Italy","JM":"Jamaica","JP":"Japan","JE":"Jersey","JO":"Jordan","KZ":"Kazakhstan","KE":"Kenya","KI":"Kiribati","KP":"Korea (Democratic People\'s Republic of)","KR":"Korea (Republic of)","KW":"Kuwait","KG":"Kyrgyzstan","LA":"Lao People\'s Democratic Republic","LV":"Latvia","LB":"Lebanon","LS":"Lesotho","LR":"Liberia","LY":"Libya","LI":"Liechtenstein","LT":"Lithuania","LU":"Luxembourg","MO":"Macao","MK":"Macedonia (the former Yugoslav Republic of)","MG":"Madagascar","MW":"Malawi","MY":"Malaysia","MV":"Maldives","ML":"Mali","MT":"Malta","MH":"Marshall Islands","MQ":"Martinique","MR":"Mauritania","MU":"Mauritius","YT":"Mayotte","MX":"Mexico","FM":"Micronesia (Federated States of)","MD":"Moldova (Republic of)","MC":"Monaco","MN":"Mongolia","ME":"Montenegro","MS":"Montserrat","MA":"Morocco","MZ":"Mozambique","MM":"Myanmar","NA":"Namibia","NR":"Nauru","NP":"Nepal","NL":"Netherlands","NC":"New Caledonia","NZ":"New Zealand","NI":"Nicaragua","NE":"Niger","NG":"Nigeria","NU":"Niue","NF":"Norfolk Island","MP":"Northern Mariana Islands","NO":"Norway","OM":"Oman","PK":"Pakistan","PW":"Palau","PS":"Palestine, State of","PA":"Panama","PG":"Papua New Guinea","PY":"Paraguay","PE":"Peru","PH":"Philippines","PN":"Pitcairn","PL":"Poland","PT":"Portugal","PR":"Puerto Rico","QA":"Qatar","RE":"RAcunion","RO":"Romania","RU":"Russian Federation","RW":"Rwanda","BL":"Saint BarthAclemy","SH":"Saint Helena, Ascension and Tristan da Cunha","KN":"Saint Kitts and Nevis","LC":"Saint Lucia","MF":"Saint Martin (French part)","PM":"Saint Pierre and Miquelon","VC":"Saint Vincent and the Grenadines","WS":"Samoa","SM":"San Marino","ST":"Sao Tome and Principe","SA":"Saudi Arabia","SN":"Senegal","RS":"Serbia","SC":"Seychelles","SL":"Sierra Leone","SG":"Singapore","SX":"Sint Maarten (Dutch part)","SK":"Slovakia","SI":"Slovenia","SB":"Solomon Islands","SO":"Somalia","ZA":"South Africa","GS":"South Georgia and the South Sandwich Islands","SS":"South Sudan","ES":"Spain","LK":"Sri Lanka","SD":"Sudan","SR":"Suriname","SJ":"Svalbard and Jan Mayen","SZ":"Swaziland","SE":"Sweden","CH":"Switzerland","SY":"Syrian Arab Republic","TW":"Taiwan, Province of China","TJ":"Tajikistan","TZ":"Tanzania, United Republic of","TH":"Thailand","TL":"Timor-Leste","TG":"Togo","TK":"Tokelau","TO":"Tonga","TT":"Trinidad and Tobago","TN":"Tunisia","TR":"Turkey","TM":"Turkmenistan","TC":"Turks and Caicos Islands","TV":"Tuvalu","UG":"Uganda","UA":"Ukraine","AE":"United Arab Emirates","GB":"United Kingdom of Great Britain and Northern Ireland","US":"United States of America","UM":"United States Minor Outlying Islands","UY":"Uruguay","UZ":"Uzbekistan","VU":"Vanuatu","VE":"Venezuela (Bolivarian Republic of)","VN":"Viet Nam","VG":"Virgin Islands (British)","VI":"Virgin Islands (U.S.)","WF":"Wallis and Futuna","EH":"Western Sahara","YE":"Yemen","ZM":"Zambia","ZW":"Zimbabwe"}' + ); var countryEM = reply.getElementsByTagName("em")[0]; var newCountryStr = country[countryEM.textContent.substr(1, 2)]; countryEM.textContent = "[" + newCountryStr + "]"; @@ -389,7 +452,9 @@ function checkBlackList(reply) { }); // Check name/trip - var msg_name = reply.firstElementChild.getElementsByClassName("name")[0].textContent.toLowerCase(); + var msg_name = reply.firstElementChild + .getElementsByClassName("name")[0] + .textContent.toLowerCase(); hide_name.forEach(v => { if (msg_name.includes(hide_name[i])) { hidepost(reply); @@ -397,13 +462,14 @@ function checkBlackList(reply) { }); // Check ID - var date_div = reply.firstElementChild.getElementsByClassName("date")[0].textContent; + var date_div = reply.firstElementChild.getElementsByClassName("date")[0] + .textContent; var id_index = date_div.indexOf("ID:"); - if(id_index != -1) { - var id = date_div.substr(id_index+3); + if (id_index != -1) { + var id = date_div.substr(id_index + 3); hide_id.forEach(v => { - if(id.includes(v)) { + if (id.includes(v)) { hidepost(reply); } }); @@ -418,19 +484,31 @@ function paintIds(reply) { var userId = dateId.textContent.split("ID:")[1]; var idColor = toHex(userId).substring(0, 6); var reverseColor = invertColor(idColor); - var lastChar = userId.substring(userId.length-1, userId.length); - dateId.innerHTML = postDate + "ID:" + userId + ""; - dateId.getElementsByClassName("uid")[0].addEventListener("click", markId, false) + var lastChar = userId.substring(userId.length - 1, userId.length); + dateId.innerHTML = + postDate + + "ID:" + + userId + + ""; + dateId + .getElementsByClassName("uid")[0] + .addEventListener("click", markId, false); } } function markId(e) { - var uid = this.textContent.slice(0,-1).replace(":","_"); + var uid = this.textContent.slice(0, -1).replace(":", "_"); var sel = document.getElementsByClassName("sel"); var len = sel.length; - for (i=0; i") + "\n"; - insert(">>"+num+"\n"+sel); + insert(">>" + num + "\n" + sel); } function insert(text) { - var textarea=document.forms.postform.message; - if(textarea) { - if(textarea.createTextRange && textarea.caretPos) { // IE - var caretPos=textarea.caretPos; - caretPos.text=caretPos.text.charAt(caretPos.text.length-1)==" "?text+" ":text; - } else if(textarea.setSelectionRange) { // Firefox - var start=textarea.selectionStart; - var end=textarea.selectionEnd; - textarea.value=textarea.value.substr(0,start)+text+textarea.value.substr(end); - textarea.setSelectionRange(start+text.length,start+text.length); - } else { textarea.value+=text+" "; } - textarea.focus(); - } + var textarea = document.forms.postform.message; + if (textarea) { + if (textarea.createTextRange && textarea.caretPos) { + // IE + var caretPos = textarea.caretPos; + caretPos.text = + caretPos.text.charAt(caretPos.text.length - 1) == " " + ? text + " " + : text; + } else if (textarea.setSelectionRange) { + // Firefox + var start = textarea.selectionStart; + var end = textarea.selectionEnd; + textarea.value = + textarea.value.substr(0, start) + text + textarea.value.substr(end); + textarea.setSelectionRange(start + text.length, start + text.length); + } else { + textarea.value += text + " "; + } + textarea.focus(); + } return false; } -function quote(b, a) { - var v = eval("document." + a + ".message"); - v.value += ">>" + b + "a\ndfs"; - v.focus(); +function quote(b, a) { + var v = eval("document." + a + ".message"); + v.value += ">>" + b + "a\ndfs"; + v.focus(); } function checkhighlight() { - var match; - if(match=/#i([0-9]+)/.exec(document.location.toString())) - if(!document.forms.postform.message.value) - insert(">>"+match[1]+"\r\n"); - if(match=/#([0-9]+)/.exec(document.location.toString())) - highlight(match[1]); + var match; + if ((match = /#i([0-9]+)/.exec(document.location.toString()))) + if (!document.forms.postform.message.value) + insert(">>" + match[1] + "\r\n"); + if ((match = /#([0-9]+)/.exec(document.location.toString()))) + highlight(match[1]); } function highlight(post) { - var cells = document.getElementsByClassName("reply"); - for(var i=0;i 900) var ratio = Math.min((window.innerWidth-130) / img_w, 1); - else var ratio = Math.min((window.innerWidth-40) / img_w, 1); + if (window.innerWidth > 900) + var ratio = Math.min((window.innerWidth - 130) / img_w, 1); + else var ratio = Math.min((window.innerWidth - 40) / img_w, 1); + + if (thumb_w < 1) return true; - if(thumb_w < 1) return true; - var img_cont = document.getElementById("thumb" + post_id); - var post_block = img_cont.parentElement.parentElement.getElementsByTagName("blockquote")[0]; + var post_block = img_cont.parentElement.parentElement.getElementsByTagName( + "blockquote" + )[0]; var img; - - for(var i = 0; i < img_cont.childNodes.length; i++) - if(img_cont.childNodes[i].nodeName.toLowerCase() == "img") { + + for (var i = 0; i < img_cont.childNodes.length; i++) + if (img_cont.childNodes[i].nodeName.toLowerCase() == "img") { img = img_cont.childNodes[i]; - } else if(img_cont.childNodes[i].nodeName.toLowerCase() == "video") { + } else if (img_cont.childNodes[i].nodeName.toLowerCase() == "video") { img = img_cont.childNodes[i]; exp_vid = 1; } - - if(img) { - if( (format == "webm") && (exp_vid == 0) ) var new_img = document.createElement("video"); + + if (img) { + if (format == "webm" && exp_vid == 0) + var new_img = document.createElement("video"); else var new_img = document.createElement("img"); new_img.setAttribute("class", "thumb"); new_img.setAttribute("alt", "" + post_id); - - if( (img.getAttribute("width") == ("" + thumb_w)) && (img.getAttribute("height") == ("" + thumb_h)) ) { + + if ( + img.getAttribute("width") == "" + thumb_w && + img.getAttribute("height") == "" + thumb_h + ) { // thumbnail -> fullsize - if(format == "webm") { + if (format == "webm") { new_img.setAttribute("controls", ""); new_img.setAttribute("loop", ""); new_img.setAttribute("autoplay", ""); @@ -120,12 +136,19 @@ function expandimg(e) { new_img.setAttribute("src", "" + img_url); new_img.setAttribute("width", img_w); new_img.setAttribute("height", img_h); - new_img.setAttribute("style", "max-width:"+Math.floor((img_w*ratio))+"px;max-height:"+Math.floor((img_h*ratio))+"px;"); + new_img.setAttribute( + "style", + "max-width:" + + Math.floor(img_w * ratio) + + "px;max-height:" + + Math.floor(img_h * ratio) + + "px;" + ); post_block.setAttribute("style", ""); - img_cont.style.display = 'table'; + img_cont.style.display = "table"; } else { // fullsize -> thumbnail - if(format == "webm") { + if (format == "webm") { new_img.removeAttribute("controls"); new_img.removeAttribute("loop"); new_img.removeAttribute("autoplay"); @@ -133,12 +156,19 @@ function expandimg(e) { new_img.setAttribute("src", "" + thumb_url); new_img.setAttribute("width", thumb_w); new_img.setAttribute("height", thumb_h); - post_block.setAttribute("style", "margin-left:"+(parseInt(thumb_w)+40)+"px;max-width:"+(1000-parseInt(thumb_w))+"px"); + post_block.setAttribute( + "style", + "margin-left:" + + (parseInt(thumb_w) + 40) + + "px;max-width:" + + (1000 - parseInt(thumb_w)) + + "px" + ); img_cont.removeAttribute("style"); } - while(img_cont.lastChild) img_cont.removeChild(img_cont.lastChild); - + while (img_cont.lastChild) img_cont.removeChild(img_cont.lastChild); + img_cont.appendChild(new_img); } } @@ -149,21 +179,38 @@ function filePreview(e) { var prev = document.getElementById("filepreview"); var noimg = document.getElementById("noimage"); if (noimg) noimg = document.getElementById("noimage").parentNode; - if (file.size > (maxsize*1024)) { inpt.value = ""; return alert("El archivo es muy grande. El tamaño máximo es " + maxsize + " KB."); } - if (!types.includes(inpt.value.slice(inpt.value.lastIndexOf(".")+1).toUpperCase())) { inpt.value = ""; return alert("Tipo de archivo no soportado."); } + if (file.size > maxsize * 1024) { + inpt.value = ""; + return alert( + "El archivo es muy grande. El tamaño máximo es " + maxsize + " KB." + ); + } + if ( + !types.includes( + inpt.value.slice(inpt.value.lastIndexOf(".") + 1).toUpperCase() + ) + ) { + inpt.value = ""; + return alert("Tipo de archivo no soportado."); + } var read = new FileReader(); read.readAsDataURL(file); - read.onload = function(){ + read.onload = function() { inpt.style.display = "none"; if (noimg) noimg.style.display = "none"; prev.removeAttribute("style"); - var fname = (file.name.length < 20) ? file.name : file.name.substr(0, 19) + "…"; - if (file.type.startsWith("image")) prev.insertAdjacentHTML('beforeend', ' ' + fname); - else prev.insertAdjacentHTML('beforeend', fname); + var fname = + file.name.length < 20 ? file.name : file.name.substr(0, 19) + "…"; + if (file.type.startsWith("image")) + prev.insertAdjacentHTML( + "beforeend", + ' ' + fname + ); + else prev.insertAdjacentHTML("beforeend", fname); prev.appendChild(document.createTextNode(" [")); var btn = document.createElement("a"); btn.href = "#"; - btn.innerText = "Quitar" + btn.innerText = "Quitar"; btn.addEventListener("click", function(e) { e.preventDefault(); prev.innerHTML = ""; @@ -178,11 +225,13 @@ function filePreview(e) { } function togglethread(e) { - if(e.parentElement.id.startsWith("unhide")) { + if (e.parentElement.id.startsWith("unhide")) { var threadid = e.parentElement.id.substr(6); - } else if(e.parentElement.parentElement.id.startsWith("thread")) { + } else if (e.parentElement.parentElement.id.startsWith("thread")) { var threadid = e.parentElement.parentElement.id.substr(6); - } else { return; } + } else { + return; + } if (hiddenthreads.toString().indexOf(threadid) !== -1) { document.getElementById("unhide" + threadid).style.display = "none"; document.getElementById("thread" + threadid).removeAttribute("style"); @@ -199,46 +248,64 @@ function togglethread(e) { function saveInputs(e) { var e = e || window.event; var form = e.target || e.srcElement; - if(typeof(form.fielda) !== "undefined") weabot.name = form.fielda.value; - if(typeof(form.fielda) !== "undefined") weabot.email = form.fieldb.value; + if (typeof form.fielda !== "undefined") weabot.name = form.fielda.value; + if (typeof form.fielda !== "undefined") weabot.email = form.fieldb.value; localStorage.setItem("weabot", JSON.stringify(weabot)); } function setInputs(id) { if (document.getElementById(id)) { - with(document.getElementById(id)) { - if(typeof(fielda) !== 'undefined' && !fielda.value && weabot.name) fielda.value = weabot.name; - if(typeof(fielda) !== 'undefined' && !fieldb.value && weabot.email) fieldb.value = weabot.email; - if(!password.value) password.value = getPassword(); - addEventListener("submit", saveInputs); + with (document.getElementById(id)) { + if (typeof fielda !== "undefined" && !fielda.value && weabot.name) + fielda.value = weabot.name; + if (typeof fielda !== "undefined" && !fieldb.value && weabot.email) + fieldb.value = weabot.email; + if (!password.value) password.value = getPassword(); + addEventListener("submit", saveInputs); } } } function getPassword() { if (weabot.password) return weabot.password; - var pass=""; - var char="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!-_."; - while (pass.length<10) { - pass += char[Math.floor(Math.random()*char.length)]; + var pass = ""; + var char = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!-_."; + while (pass.length < 10) { + pass += char[Math.floor(Math.random() * char.length)]; } weabot.password = pass; localStorage.setItem("weabot", JSON.stringify(weabot)); - return(pass); + return pass; } function catSort(type) { - for(var i=0;i"; + for (var i = 0; i < srt.length; i++) srt[i].innerHTML = srt[i].innerText; + srt[type].innerHTML = "" + srt[type].innerText + ""; var cont = document.getElementById("catalog"); var elem = document.getElementsByClassName("thread"); var arr = Array.prototype.slice.call(elem); - if (type==0) arr.sort(function (a,b) { return (a.dataset.num-b.dataset.num) }); - else if (type==1) arr.sort(function (a,b) { return (b.dataset.id-a.dataset.id) }); - else if (type==2) arr.sort(function (a,b) { return (a.dataset.id-b.dataset.id) }); - else if (type==3) arr.sort(function (a,b) { return (b.dataset.res-a.dataset.res) }); - else if (type==4) arr.sort(function (a,b) { return (a.dataset.res-b.dataset.res) }); - for (var j=0;j[Denunciar] [Ocultar]'); + this.insertAdjacentHTML( + "afterbegin", + '
[Denunciar] [Ocultar]' + ); this.getElementsByClassName("hh")[0].addEventListener("click", function(e) { document.getElementById("cat" + id + brd).style.display = "none"; hiddenthreads.push(id + brd); - localStorage.setItem("hiddenthreads", hiddenthreads.join("!")) - if (document.getElementById("hidden_label")) { hidden_num++; document.getElementById("hidden_num").innerText = hidden_num; } - else { hidden_num = 1; catHidden(); } + localStorage.setItem("hiddenthreads", hiddenthreads.join("!")); + if (document.getElementById("hidden_label")) { + hidden_num++; + document.getElementById("hidden_num").innerText = hidden_num; + } else { + hidden_num = 1; + catHidden(); + } }); } -function catMenuClose(e) { document.getElementById("thread_ctrl").remove(); } +function catMenuClose(e) { + document.getElementById("thread_ctrl").remove(); +} function catHidden() { var menu = document.getElementById("ctrl"); - menu.insertAdjacentHTML('beforeend', ' [Hilos ocultos: ' + hidden_num + ' - '); + menu.insertAdjacentHTML( + "beforeend", + ' [Hilos ocultos: ' + + hidden_num + + " - " + ); var lbl = document.getElementById("hidden_label"); var shw = document.createElement("a"); - shw.href = "#"; shw.innerText = "Deshacer"; + shw.href = "#"; + shw.innerText = "Deshacer"; shw.addEventListener("click", function(e) { e.preventDefault(); - for(var i=0;i= thresh && u < units.length - 1); - return B.toFixed(1)+" "+units[u]; + } while (Math.abs(B) >= thresh && u < units.length - 1); + return B.toFixed(1) + " " + units[u]; } -function fixFileSize(){ +function fixFileSize() { var obj = document.getElementsByClassName("fs"); - for (var i=0; i")+"\n"; sel="\n"+sel; } - insert(">>"+num+sel); + if (sel) { + sel = sel.replace(/^/gm, ">") + "\n"; + sel = "\n" + sel; + } + insert(">>" + num + sel); } function previewPost(e) { var formid = e.target.id; var thread = "0"; - if(formid.startsWith("postform")) thread = formid.substr(8); + if (formid.startsWith("postform")) thread = formid.substr(8); - var form=document.getElementById(formid); - var preview=document.getElementById("preview"+thread); - var main=document.getElementById("options"); + var form = document.getElementById(formid); + var preview = document.getElementById("preview" + thread); + var main = document.getElementById("options"); - if(!form||!preview||!form.message.value) return; - if(main) main.style.display=""; + if (!form || !preview || !form.message.value) return; + if (main) main.style.display = ""; preview.removeAttribute("style"); - preview.innerHTML="Cargando..."; + preview.innerHTML = "Cargando..."; - var text="message="+encodeURIComponent(form.message.value)+"&board="+board; - if (thread) text+="&parentid="+thread; + var text = + "message=" + encodeURIComponent(form.message.value) + "&board=" + board; + if (thread) text += "&parentid=" + thread; - var xmlhttp=get_xmlhttp(); - xmlhttp.open("POST", "/cgi/preview"); - xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) preview.innerHTML=xmlhttp.responseText; } - if(is_ie()||xmlhttp.setRequestHeader) xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); - xmlhttp.send(text); + var xmlhttp = get_xmlhttp(); + xmlhttp.open("POST", "/cgi/preview"); + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == 4) preview.innerHTML = xmlhttp.responseText; + }; + if (is_ie() || xmlhttp.setRequestHeader) + xmlhttp.setRequestHeader( + "Content-Type", + "application/x-www-form-urlencoded" + ); + 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); arr.shift(); - if (s=="Normal") { arr.sort(function (a,b) { 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]) }); } - else if(s=="Largo"){ arr.sort(function (a,b) { 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]))) }); } - else if(s=="Aleatorio"){ arr.sort(function(a,b) { return 0.5-Math.random()}); } - for (var j=0;j