aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--static/js/aquiencitas.js165
-rw-r--r--static/js/autorefresh.js263
-rw-r--r--static/js/home.js144
-rw-r--r--static/js/manage.js11
-rw-r--r--static/js/mobile.js370
-rwxr-xr-xstatic/js/palette_selfy.js1992
-rw-r--r--static/js/shobon.js400
-rw-r--r--static/js/weabot.js484
-rw-r--r--static/js/weabotxt.js353
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<ss) { tmp=ss;ss=ee;ee=tmp; rev=true; }
- for(j = 0; j < replies.length; j++) {
+ if (s.length == 2) ee = parseInt(s[1]);
+ if (ee < ss) {
+ tmp = ss;
+ ss = ee;
+ ee = tmp;
+ rev = true;
+ }
+ for (j = 0; j < replies.length; j++) {
num = parseInt(replies[j].dataset.n);
- if(num > 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<rs.length;i++) { divs.push.apply(divs, getPostRange(t, rs[i])); }
+ for (i = 0; i < rs.length; i++) {
+ divs.push.apply(divs, getPostRange(t, rs[i]));
+ }
return divs;
} else {
- ele = document.getElementById('reply' + e.getAttribute('href').split('#')[1]);
- return [ele,];
+ ele = document.getElementById(
+ "reply" + e.getAttribute("href").split("#")[1]
+ );
+ return [ele];
}
}
function get_pid(e) {
@@ -46,36 +64,37 @@ function get_pid(e) {
}
function fill_links(e) {
var divs = getPostDivs(e);
- if(!divs[0]) return;
-
+ if (!divs[0]) return;
+
this_id = get_pid(e.parentNode.parentNode);
-
- for(i=0;i<divs.length;i++) {
+
+ for (i = 0; i < divs.length; i++) {
tid = get_pid(divs[i]);
- if (linklist[tid])
- continue;
- if (this_id == tid)
- continue;
- t = (is_bbs ? divs[i].getElementsByTagName("h4")[0] : divs[i]);
- bl = document.createElement('a');
+ if (linklist[tid]) continue;
+ if (this_id == tid) continue;
+ t = is_bbs ? divs[i].getElementsByTagName("h4")[0] : divs[i];
+ bl = document.createElement("a");
bl.href = cur_url + (is_bbs ? "/" : "#") + this_id;
- bl.textContent = '>>' + this_id;
- bl.addEventListener('mouseover', who_are_you_quoting, false);
- bl.addEventListener('mouseout', remove_quote_preview, false);
- if (!(qb = t.getElementsByClassName('quoted')[0])) {
- qb = document.createElement((is_bbs ? 'span' : 'div'));
- qb.className = 'quoted';
- qb.textContent = ' Citado por: ';
- if(is_bbs) {
+ bl.textContent = ">>" + this_id;
+ bl.addEventListener("mouseover", who_are_you_quoting, false);
+ bl.addEventListener("mouseout", remove_quote_preview, false);
+ if (!(qb = t.getElementsByClassName("quoted")[0])) {
+ qb = document.createElement(is_bbs ? "span" : "div");
+ qb.className = "quoted";
+ qb.textContent = " Citado por: ";
+ if (is_bbs) {
t.insertBefore(qb, t.getElementsByClassName("del")[0]);
- t.insertBefore(document.createTextNode(' '), t.getElementsByClassName("del")[0]);
+ t.insertBefore(
+ document.createTextNode(" "),
+ t.getElementsByClassName("del")[0]
+ );
} else {
p = t.getElementsByTagName("blockquote");
- p[p.length-1].insertAdjacentHTML('afterend', qb.outerHTML);
+ p[p.length - 1].insertAdjacentHTML("afterend", qb.outerHTML);
}
- t.getElementsByClassName('quoted')[0].appendChild(bl);
+ t.getElementsByClassName("quoted")[0].appendChild(bl);
} else {
- qb.appendChild(document.createTextNode(' '));
+ qb.appendChild(document.createTextNode(" "));
qb.appendChild(bl);
}
linklist[tid] = true;
@@ -85,17 +104,17 @@ function who_are_you_quoting(e) {
var parent, d, clr, src, cnt, left, top, width, maxWidth;
e = e.target || window.event.srcElement;
var divs = getPostDivs(e);
- if(!divs[0]) return;
-
+ if (!divs[0]) return;
+
maxWidth = 500;
- cnt = document.createElement('div');
- cnt.id = 'q-p';
+ cnt = document.createElement("div");
+ cnt.id = "q-p";
width = divs[0].offsetWidth;
if (width > maxWidth) {
width = maxWidth;
}
-
- for(i=0;i<divs.length&&i<plimit;i++) {
+
+ for (i = 0; i < divs.length && i < plimit; i++) {
src = divs[i].cloneNode(true);
cnt.appendChild(src);
}
@@ -105,15 +124,14 @@ function who_are_you_quoting(e) {
do {
left += parent.offsetLeft;
top += parent.offsetTop;
- } while (parent = parent.offsetParent);
+ } while ((parent = parent.offsetParent));
if ((d = document.body.offsetWidth - left - width) < 0) left += d;
- cnt.setAttribute('style', 'left:' + left + 'px;top:' + top + 'px;');
+ cnt.setAttribute("style", "left:" + left + "px;top:" + top + "px;");
document.body.appendChild(cnt);
}
function remove_quote_preview(e) {
var cnt;
- if (cnt = document.getElementById('q-p'))
- document.body.removeChild(cnt);
+ if ((cnt = document.getElementById("q-p"))) document.body.removeChild(cnt);
}
/*function goTo(e) {
e.preventDefault();
@@ -123,40 +141,47 @@ function remove_quote_preview(e) {
if (pst) pst.scrollIntoView();
}*/
function quotePreview() {
- if(localStorage.getItem("shobon_on") == "false") { return; }
- if(localStorage.getItem("shobon_preview") == "false" && localStorage.getItem("shobon_backlink") == "false") { return; }
-
+ if (localStorage.getItem("shobon_on") == "false") {
+ return;
+ }
+ if (
+ localStorage.getItem("shobon_preview") == "false" &&
+ localStorage.getItem("shobon_backlink") == "false"
+ ) {
+ return;
+ }
+
var i, q, replies, quotes;
-
- if(document.body.className && document.body.className != "res")
+
+ if (document.body.className && document.body.className != "res")
is_bbs = true;
else is_bbs = false;
-
- if(is_bbs) replies = document.getElementsByClassName('msg');
- else replies = document.getElementsByTagName('blockquote');
-
+
+ if (is_bbs) replies = document.getElementsByClassName("msg");
+ else replies = document.getElementsByTagName("blockquote");
+
urls = window.location.pathname.split("/");
cur_url = urls[0] + "/" + urls[1] + "/" + urls[2] + "/" + urls[3];
-
+
for (x = 0; x < replies.length; x++) {
- quotes = replies[x].getElementsByTagName('a');
+ quotes = replies[x].getElementsByTagName("a");
linklist = {};
-
+
for (i = 0; i < quotes.length; i++) {
q = quotes[i];
- 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 (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<q.length;j++) {
@@ -165,4 +190,4 @@ function quotePreview() {
}
}*/
}
-document.addEventListener('DOMContentLoaded', quotePreview, false); \ No newline at end of file
+document.addEventListener("DOMContentLoaded", quotePreview, false);
diff --git a/static/js/autorefresh.js b/static/js/autorefresh.js
index 3f9dbd4..cec1e33 100644
--- a/static/js/autorefresh.js
+++ b/static/js/autorefresh.js
@@ -18,15 +18,21 @@ function checkNew(e) {
}
function loadJSON() {
- if (chk.checked)
- stopCounter("...");
- if (manual)
- document.getElementById("counter").innerText = "...";
+ if (chk.checked) stopCounter("...");
+ if (manual) document.getElementById("counter").innerText = "...";
var data_file;
if (serviceType == 2 || serviceType == 3) {
board = document.getElementsByName("board")[0].value;
parent = document.getElementsByName("parent")[0].value;
- data_file = "/cgi/api/thread?dir=" + board + "&id=" + parent + "&offset=" + thread_length + "&time=" + lastTime;
+ data_file =
+ "/cgi/api/thread?dir=" +
+ board +
+ "&id=" +
+ parent +
+ "&offset=" +
+ thread_length +
+ "&time=" +
+ lastTime;
} else {
return false;
}
@@ -38,69 +44,220 @@ function updateThread(posts, total_replies, serverTime) {
var thread_div = document.getElementsByClassName("thread")[0];
if (serviceType == 2) var last_elem = document.getElementById("size");
else var last_elem = document.getElementsByClassName("cut")[0];
- for (var i=0; i<posts.length; i++) {
+ for (var i = 0; i < posts.length; i++) {
post = posts[i];
var num = thread_length + i + 1;
- var div = document.createElement('div');
+ var div = document.createElement("div");
if (serviceType == 2) div.className = "reply";
else div.className = "replycont";
if (post.email) {
- if (post.tripcode) s_name = '<a href="mailto:' + post.email + '"><span class="name"><b>' + post.name + '</b> ' + post.tripcode + '</span></a>';
- else s_name = '<a href="mailto:' + post.email + '"><span class="name"><b>' + post.name + '</b></span></a>';
+ if (post.tripcode)
+ s_name =
+ '<a href="mailto:' +
+ post.email +
+ '"><span class="name"><b>' +
+ post.name +
+ "</b> " +
+ post.tripcode +
+ "</span></a>";
+ else
+ s_name =
+ '<a href="mailto:' +
+ post.email +
+ '"><span class="name"><b>' +
+ post.name +
+ "</b></span></a>";
} else {
- if (post.tripcode) s_name = '<span class="name"><b>' + post.name + '</b> ' + post.tripcode + '</span>';
- else s_name = '<span class="name"><b>' + post.name + '</b></span>';
+ if (post.tripcode)
+ s_name =
+ '<span class="name"><b>' +
+ post.name +
+ "</b> " +
+ post.tripcode +
+ "</span>";
+ else s_name = '<span class="name"><b>' + post.name + "</b></span>";
}
if (serviceType == 2) {
if (post.file) {
- s_img = '<a href="/' + board + '/src/' + post.file + '" target="_blank" class="thumb"><img src="/' + board + '/thumb/' + post.thumb + '" width="' + post.thumb_width + '" height="' + post.thumb_height + '" /><br />' + Math.round(post.file_size/1024) + 'KB ' + post.file.substring(post.file.lastIndexOf(".")+1, post.file.length).toUpperCase() + '</a>';
- } else s_img = '';
- if (post.IS_DELETED == 1) div.innerHTML = '<h4 class="deleted">' + num + ' : Mensaje eliminado por el usuario.</h4>';
- else if (post.IS_DELETED == 2) div.innerHTML = '<h4 class="deleted">' + num + ' : Mensaje eliminado por miembro del staff.</h4>';
- else
- div.innerHTML = '<h4><a class="num" href="#">' + num + '</a> : ' + s_name + ' : <span class="date" data-unix="' + post.timestamp + '">' + post.timestamp_formatted + '</span> <span class="del"><a href="/cgi/report/' + board + '/' + post.id + '/' + num + '">rep</a> <a href="#">del</a></span></h4>' + s_img + '<div class="msg">' + post.message + '</div>';
+ s_img =
+ '<a href="/' +
+ board +
+ "/src/" +
+ post.file +
+ '" target="_blank" class="thumb"><img src="/' +
+ board +
+ "/thumb/" +
+ post.thumb +
+ '" width="' +
+ post.thumb_width +
+ '" height="' +
+ post.thumb_height +
+ '" /><br />' +
+ Math.round(post.file_size / 1024) +
+ "KB " +
+ post.file
+ .substring(post.file.lastIndexOf(".") + 1, post.file.length)
+ .toUpperCase() +
+ "</a>";
+ } else s_img = "";
+ if (post.IS_DELETED == 1)
+ div.innerHTML =
+ '<h4 class="deleted">' +
+ num +
+ " : Mensaje eliminado por el usuario.</h4>";
+ else if (post.IS_DELETED == 2)
+ div.innerHTML =
+ '<h4 class="deleted">' +
+ num +
+ " : Mensaje eliminado por miembro del staff.</h4>";
+ else
+ div.innerHTML =
+ '<h4><a class="num" href="#">' +
+ num +
+ "</a> : " +
+ s_name +
+ ' : <span class="date" data-unix="' +
+ post.timestamp +
+ '">' +
+ post.timestamp_formatted +
+ '</span> <span class="del"><a href="/cgi/report/' +
+ board +
+ "/" +
+ post.id +
+ "/" +
+ num +
+ '">rep</a> <a href="#">del</a></span></h4>' +
+ s_img +
+ '<div class="msg">' +
+ post.message +
+ "</div>";
} else {
if (post.file) {
if (post.image_width != 0) {
- s_img = '<div class="fs"><a href="/' + board + '/src/' + post.file + '" class="expimg" data-id="' + post.id + '" data-thumb="/' + board + '/thumb/' + post.thumb + '" data-w="' + post.image_width + '" data-h="' + post.image_height + '" data-tw="' + post.thumb_width + '" data-th="' + post.thumb_height + '">' + post.file + '</a>-(' + post.file_size+ ' B, ' + post.image_width + 'x' + post.image_height + ')</div>';
+ s_img =
+ '<div class="fs"><a href="/' +
+ board +
+ "/src/" +
+ post.file +
+ '" class="expimg" data-id="' +
+ post.id +
+ '" data-thumb="/' +
+ board +
+ "/thumb/" +
+ post.thumb +
+ '" data-w="' +
+ post.image_width +
+ '" data-h="' +
+ post.image_height +
+ '" data-tw="' +
+ post.thumb_width +
+ '" data-th="' +
+ post.thumb_height +
+ '">' +
+ post.file +
+ "</a>-(" +
+ post.file_size +
+ " B, " +
+ post.image_width +
+ "x" +
+ post.image_height +
+ ")</div>";
} else {
- s_img = '<div class="fs"><a href="/' + board + '/src/' + post.file + '" target="_blank">' + post.file + '</a>-(' + post.file_size+ ' B)</div>';
+ s_img =
+ '<div class="fs"><a href="/' +
+ board +
+ "/src/" +
+ post.file +
+ '" target="_blank">' +
+ post.file +
+ "</a>-(" +
+ post.file_size +
+ " B)</div>";
}
- s_img += '<a target="_blank" href="/' + board + '/src/' + post.file + '" id="thumb' + post.id + '"><img class="thumb" alt="' + post.id + '" src="/' + board + '/thumb/' + post.thumb + '" width="' + post.thumb_width + '" height="' + post.thumb_height + '" /></a>';
- s_msg = '<blockquote style="margin-left:' + (post.thumb_width+40) + 'px;">' + post.message + '</blockquote>';
+ s_img +=
+ '<a target="_blank" href="/' +
+ board +
+ "/src/" +
+ post.file +
+ '" id="thumb' +
+ post.id +
+ '"><img class="thumb" alt="' +
+ post.id +
+ '" src="/' +
+ board +
+ "/thumb/" +
+ post.thumb +
+ '" width="' +
+ post.thumb_width +
+ '" height="' +
+ post.thumb_height +
+ '" /></a>';
+ s_msg =
+ '<blockquote style="margin-left:' +
+ (post.thumb_width + 40) +
+ 'px;">' +
+ post.message +
+ "</blockquote>";
} else {
- s_img = '';
- s_msg = '<blockquote>' + post.message + '</blockquote>';
+ s_img = "";
+ s_msg = "<blockquote>" + post.message + "</blockquote>";
}
if (post.IS_DELETED == 0) {
- div.innerHTML = '<table border="0"><tr><td class="ell">…</td><td class="reply" id="reply' + post.id + '"><div class="info"><input type="checkbox" name="delete" value="' + post.id + '" />' + (post.subject ? (' <span class="subj">' + post.subject + '</span>') : '') + ' ' + s_name + ' ' + '<span class="date" data-unix="' + post.timestamp + '">' + post.timestamp_formatted + '</span> <span class="reflink"><a href="#' + post.id + '">No.</a><a href="#" class="postid">' + post.id + '</a></span> <a class="rep" href="/cgi/report/' + board + '/' + post.id + '">rep</a></div>' + s_img + s_msg + '</td></tr></table>';
+ div.innerHTML =
+ '<table border="0"><tr><td class="ell">…</td><td class="reply" id="reply' +
+ post.id +
+ '"><div class="info"><input type="checkbox" name="delete" value="' +
+ post.id +
+ '" />' +
+ (post.subject
+ ? ' <span class="subj">' + post.subject + "</span>"
+ : "") +
+ " " +
+ s_name +
+ " " +
+ '<span class="date" data-unix="' +
+ post.timestamp +
+ '">' +
+ post.timestamp_formatted +
+ '</span> <span class="reflink"><a href="#' +
+ post.id +
+ '">No.</a><a href="#" class="postid">' +
+ post.id +
+ '</a></span> <a class="rep" href="/cgi/report/' +
+ board +
+ "/" +
+ post.id +
+ '">rep</a></div>' +
+ s_img +
+ s_msg +
+ "</td></tr></table>";
}
}
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<links.length;i++) {
- var rel=links[i].getAttribute("rel");
- var title=links[i].getAttribute("title");
- if(rel.indexOf("style")!=-1&&title) {
- links[i].disabled=true; // IE needs this to work. IE needs to die.
- if(styletitle==title) { links[i].disabled=false; found=true; }
- }
- }
+ var links = document.getElementsByTagName("link");
+ var found = false;
+ for (var i = 0; i < links.length; i++) {
+ var rel = links[i].getAttribute("rel");
+ var title = links[i].getAttribute("title");
+ if (rel.indexOf("style") != -1 && title) {
+ links[i].disabled = true; // IE needs this to work. IE needs to die.
+ if (styletitle == title) {
+ links[i].disabled = false;
+ found = true;
+ }
+ }
+ }
}
function get_active_stylesheet() {
- var links=document.getElementsByTagName("link");
- for(var i=0;i<links.length;i++) {
- var rel=links[i].getAttribute("rel");
- var title=links[i].getAttribute("title");
- if(rel.indexOf("style")!=-1&&title&&!links[i].disabled) return title;
- }
- return null;
+ var links = document.getElementsByTagName("link");
+ for (var i = 0; i < links.length; i++) {
+ var rel = links[i].getAttribute("rel");
+ var title = links[i].getAttribute("title");
+ if (rel.indexOf("style") != -1 && title && !links[i].disabled) return title;
+ }
+ return null;
}
function check_news() {
var last_t = opcs.last;
- 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 = '<img src="/new.gif" style="width:18px;height:7px;"><br />' + 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 =
+ '<img src="/new.gif" style="width:18px;height:7px;"><br />' +
+ 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 += '<span class="new">';
- html += '<a href="' + thread.url + '" class="thread" data-brd="' + thread.board_fulln + '" data-unix="' + thread.timestamp + '" data-last="' + thread.bumped + '" data-img="' + thread.thumb + '"><span class="brd">[' + thread.board_name + ']</span> <span class="cont">' + thread.content + '</span> <span class="rep">(' + thread.length + ')</span></a>';
+ html +=
+ '<a href="' +
+ thread.url +
+ '" class="thread" data-brd="' +
+ thread.board_fulln +
+ '" data-unix="' +
+ thread.timestamp +
+ '" data-last="' +
+ thread.bumped +
+ '" data-img="' +
+ thread.thumb +
+ '"><span class="brd">[' +
+ thread.board_name +
+ ']</span> <span class="cont">' +
+ thread.content +
+ '</span> <span class="rep">(' +
+ thread.length +
+ ")</span></a>";
if (unread[thread.id]) {
- html += '</span>';
+ html += "</span>";
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<css.length;j++) {
- css[j].addEventListener("click", function(e) { e.preventDefault(); set_stylesheet(this.textContent); });
+ for (var j = 0; j < css.length; j++) {
+ css[j].addEventListener("click", function(e) {
+ e.preventDefault();
+ set_stylesheet(this.textContent);
+ });
}
- document.getElementById("autorefresh").addEventListener("click", function(e) { opcs.auto=!opcs.auto; autoRefresh(); parse(); });
- document.getElementById("autosound").addEventListener("click", function(e) { opcs.sound=!opcs.sound; parse(); });
+ document.getElementById("autorefresh").addEventListener("click", function(e) {
+ opcs.auto = !opcs.auto;
+ autoRefresh();
+ parse();
+ });
+ document.getElementById("autosound").addEventListener("click", function(e) {
+ opcs.sound = !opcs.sound;
+ parse();
+ });
check_news();
- chk=document.getElementById("autorefresh");
- chk_snd=document.getElementById("autosound");
- if (opcs.auto) { chk.checked=true; autoRefresh(); } else chk.checked=false;
- if (opcs.sound) chk_snd.checked=true; else chk_snd.checked=false;
-}); \ No newline at end of file
+ chk = document.getElementById("autorefresh");
+ chk_snd = document.getElementById("autosound");
+ if (opcs.auto) {
+ chk.checked = true;
+ autoRefresh();
+ } else chk.checked = false;
+ if (opcs.sound) chk_snd.checked = true;
+ else chk_snd.checked = false;
+});
diff --git a/static/js/manage.js b/static/js/manage.js
index 475361d..4aa1309 100644
--- a/static/js/manage.js
+++ b/static/js/manage.js
@@ -7,7 +7,9 @@ function pvw(e) {
prev = document.getElementById("prev_desc");
prev.innerHTML = desc.value;
prev.style.display = "block";
- prev.addEventListener("input", function() { desc.value = prev.innerHTML; });
+ prev.addEventListener("input", function() {
+ desc.value = prev.innerHTML;
+ });
}
function timeAgo(timestamp) {
@@ -31,14 +33,15 @@ document.addEventListener("DOMContentLoaded", function(e) {
var list = document.getElementById("timelist");
if (list) {
var secs = document.getElementById("timelist").getElementsByTagName("a");
- for(var i=0;i<secs.length;i++) secs[i].addEventListener("click", addtime);
+ for (var i = 0; i < secs.length; i++)
+ secs[i].addEventListener("click", addtime);
}
var tss = document.getElementsByName("timestamp");
- for (var i = 0; i < tss.length; i++){
+ for (var i = 0; i < tss.length; i++) {
tss[i].title = tss[i].textContent;
tss[i].textContent = timeAgo(tss[i].dataset.ts);
}
desc = document.getElementById("brd_desc");
if (desc) desc.addEventListener("input", pvw);
-}); \ No newline at end of file
+});
diff --git a/static/js/mobile.js b/static/js/mobile.js
index b4dd8cf..22606b9 100644
--- a/static/js/mobile.js
+++ b/static/js/mobile.js
@@ -10,65 +10,78 @@ function sendPost(e) {
if (sendpost.readyState == 4) {
button.disabled = false;
var response = JSON.parse(sendpost.responseText);
- if (response.state == "success") { postform.message.value = ""; checkNew(e); }
- else alert(response.message);
+ if (response.state == "success") {
+ postform.message.value = "";
+ checkNew(e);
+ } else alert(response.message);
}
- }
+ };
}
function postClick(e) {
e.preventDefault();
var sel = window.getSelection().toString();
- if (sel) { sel=sel.replace(/^/gm, ">")+"\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 = '<a href="/' + brd + '/src/' + post.file + '" target="_blank" class="thm"><img src="/' + brd + '/mobile/' + post.thumb + '" /><br />' + Math.round(post.file_size/1024) + 'KB ' + post.file.substring(post.file.lastIndexOf(".")+1, post.file.length).toUpperCase() + '</a>';
- else s_img = '';
+ s_img =
+ '<a href="/' +
+ brd +
+ "/src/" +
+ post.file +
+ '" target="_blank" class="thm"><img src="/' +
+ brd +
+ "/mobile/" +
+ post.thumb +
+ '" /><br />' +
+ Math.round(post.file_size / 1024) +
+ "KB " +
+ post.file
+ .substring(post.file.lastIndexOf(".") + 1, post.file.length)
+ .toUpperCase() +
+ "</a>";
+ 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 = '<h3><a href="#" class="num">' + pad + '</a> ' + s_name + '</h3>' + s_img + '<div class="msg">' + post.message + '</div><h4>' + s_time + '<a href="#" class="mnu">|||</a></h4>';
+ div.innerHTML =
+ '<h3><a href="#" class="num">' +
+ pad +
+ "</a> " +
+ s_name +
+ "</h3>" +
+ s_img +
+ '<div class="msg">' +
+ post.message +
+ "</div><h4>" +
+ s_time +
+ '<a href="#" class="mnu">|||</a></h4>';
else if (post.IS_DELETED == 1)
- div.innerHTML = '<h3 class="del"><a href="#" class="num">' + pad + '</a> : Eliminado por el usuario.</h3>';
+ div.innerHTML =
+ '<h3 class="del"><a href="#" class="num">' +
+ pad +
+ "</a> : Eliminado por el usuario.</h3>";
else
- div.innerHTML = '<h3 class="del"><a href="#" class="num">' + pad + '</a> : Eliminado por miembro del staff.</h3>';
+ div.innerHTML =
+ '<h3 class="del"><a href="#" class="num">' +
+ pad +
+ "</a> : Eliminado por miembro del staff.</h3>";
} else {
if (post.IS_DELETED == 0) {
- div.innerHTML = '<h3>' + s_name + ' ' + s_time + ' <a href="#" class="num" name="' + post.id + '">' + post.id + '</a><a href="#" class="mnu">|||</a></h3>' + s_img + '<div class="msg">' + post.message + '</div>';
- } else if (post.IS_DELETED == 1) { div.innerHTML = '<h3 class="del"><a name="' + post.id + '"></a>No.' + post.id + ' eliminado por el usuario.</h3>'; }
- else { div.innerHTML = '<h3 class="del"><a name="' + post.id + '"></a>No.' + post.id + ' eliminado por miembro del staff.</h3>'; }
+ div.innerHTML =
+ "<h3>" +
+ s_name +
+ " " +
+ s_time +
+ ' <a href="#" class="num" name="' +
+ post.id +
+ '">' +
+ post.id +
+ '</a><a href="#" class="mnu">|||</a></h3>' +
+ s_img +
+ '<div class="msg">' +
+ post.message +
+ "</div>";
+ } else if (post.IS_DELETED == 1) {
+ div.innerHTML =
+ '<h3 class="del"><a name="' +
+ post.id +
+ '"></a>No.' +
+ post.id +
+ " eliminado por el usuario.</h3>";
+ } else {
+ div.innerHTML =
+ '<h3 class="del"><a name="' +
+ post.id +
+ '"></a>No.' +
+ post.id +
+ " eliminado por miembro del staff.</h3>";
+ }
}
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(" \<span\>")[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(" <span>")[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<srts.length;i++) srts[i].removeAttribute("class");
+ for (var i = 0; i < srts.length; i++) srts[i].removeAttribute("class");
srts[type].className = "sel";
var cont = document.getElementById("to_sort");
var elem = cont.getElementsByTagName("a");
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<arr.length;j++) cont.appendChild(arr[j]);
+ 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 < arr.length; j++) cont.appendChild(arr[j]);
}
document.addEventListener("DOMContentLoaded", function(e) {
- if (localStorage.hasOwnProperty("weabot")) weabot = JSON.parse(localStorage.getItem("weabot"));
- else weabot = {"name":null,"email":null,"password":null};
+ if (localStorage.hasOwnProperty("weabot"))
+ weabot = JSON.parse(localStorage.getItem("weabot"));
+ else weabot = { name: null, email: null, password: null };
var ids = document.getElementsByClassName("num");
- for(var i=0;i<ids.length;i++) ids[i].addEventListener("click", postClick);
-
+ for (var i = 0; i < ids.length; i++)
+ ids[i].addEventListener("click", postClick);
+
var form = document.getElementById("postform");
if (form) {
setInputs();
if (document.getElementById("post").value == "Responder")
form.addEventListener("submit", sendPost);
}
-
- if (document.getElementById("search")) document.getElementById("search").addEventListener("keyup", searchSubjects);
- if (document.getElementById("catsearch")) document.getElementById("catsearch").addEventListener("keyup", searchCatalog);
+
+ if (document.getElementById("search"))
+ document.getElementById("search").addEventListener("keyup", searchSubjects);
+ if (document.getElementById("catsearch"))
+ document
+ .getElementById("catsearch")
+ .addEventListener("keyup", searchCatalog);
if (document.getElementById("to_sort")) {
srts = document.getElementsByClassName("ord")[0].getElementsByTagName("a");
- for(var i=0;i<srts.length;i++) srts[i].addEventListener("click", function(e) { e.preventDefault(); sortList(this.dataset.sort); });
+ for (var i = 0; i < srts.length; i++)
+ srts[i].addEventListener("click", function(e) {
+ e.preventDefault();
+ sortList(this.dataset.sort);
+ });
}
if (document.getElementById("thread")) {
- var mnu = document.createElement('a');
+ var mnu = document.createElement("a");
mnu.href = "#";
mnu.className = "mnu";
mnu.innerHTML = "|||";
- if (document.body.className === "txt") var ft = document.getElementsByTagName("h4");
- else if (document.body.className === "img") var ft = document.getElementsByTagName("h3");
- for(var i=0;i<ft.length;i++) {
+ if (document.body.className === "txt")
+ var ft = document.getElementsByTagName("h4");
+ else if (document.body.className === "img")
+ var ft = document.getElementsByTagName("h3");
+ for (var i = 0; i < ft.length; i++) {
if (!ft[i].classList.contains("del")) {
var cln = mnu.cloneNode(true);
cln.addEventListener("click", showMenu);
@@ -429,9 +605,11 @@ document.addEventListener("DOMContentLoaded", function(e) {
cnt.textContent = "OFF";
document.getElementById("n2").appendChild(lbl);
document.getElementById("auto").appendChild(btn);
- document.getElementById("auto").appendChild(document.createTextNode(" Auto "));
+ document
+ .getElementById("auto")
+ .appendChild(document.createTextNode(" Auto "));
document.getElementById("auto").appendChild(cnt);
-
+
chk = document.getElementById("autorefresh");
if (localStorage.getItem("autorefreshmobile")) {
chk.checked = true;
@@ -439,9 +617,9 @@ document.addEventListener("DOMContentLoaded", function(e) {
}
});
-window.addEventListener("unload", function() {
+window.addEventListener("unload", function() {
chk = document.getElementById("autorefresh");
if (!serviceType) return;
if (chk.checked) localStorage.setItem("autorefreshmobile", true);
else localStorage.removeItem("autorefreshmobile");
-}); \ No newline at end of file
+});
diff --git a/static/js/palette_selfy.js b/static/js/palette_selfy.js
index b17134f..eb7d594 100755
--- a/static/js/palette_selfy.js
+++ b/static/js/palette_selfy.js
@@ -1,972 +1,1328 @@
// palette_selfy.js .. for PaintBBS and ShiPainter .. last update : 2004/04/11.
//g .. OJSƂēǂݍłADȏ palette_selfy() Ăяoĉ.
- var selfv=new Array(); var selfytag=new Array(); //Ȃ.
+var selfv = new Array();
+var selfytag = new Array(); //Ȃ.
//ݒ ------------------------------------------------------------
// selfv[*] ́Aꂼ̐ݒ󔒂ɂƁA̋@\̃{^\Ȃł܂.
// +-l̂Ƃ
-var pnum = 10; // +- ̃ftHgl
-selfv[0] = 'size=3 style="text-align:right">'; // l^O(type=text)̒g
-
+var pnum = 10; // +- ̃ftHgl
+selfv[0] = 'size=3 style="text-align:right">'; // l^O(type=text)̒g
// pbgXg.
// ..evf̒̐F́A1‚Ȃ瑼13F͂̐FɁ2ʂ肩玩擾A
-var psx = 0; // 0:ʓx+x. 1:Fz‚.
+var psx = 0; // 0:ʓx+x. 1:Fz‚.
// ʓx+xɂƂ̐F. (ݒ肷ꍇ́A11‚̐F \n ŋ؂)
var pdefs = new Array(
- '#ffffff',
- '#ffe6e6','#ffece6','#fff3e6','#fff9e6','#ffffe6',
- '#f3ffe6','#e6fff3','#e6f3ff','#ffe6ff','#eeddbb',
-''); // 󔒂Ƃ̗vf̓XLbv.
+ "#ffffff",
+ "#ffe6e6",
+ "#ffece6",
+ "#fff3e6",
+ "#fff9e6",
+ "#ffffe6",
+ "#f3ffe6",
+ "#e6fff3",
+ "#e6f3ff",
+ "#ffe6ff",
+ "#eeddbb",
+ ""
+); // 󔒂Ƃ̗vf̓XLbv.
// Fŏz‚Ƃ̐F. (ݒ肷ꍇ́A11‚̐F \n ŋ؂)
var pdefx = new Array(
- '#ffffff',
- '#ffe6e6','#ffcccc','#ff9999','#e6cccc','#e69999',
- '#cc9999','#cc6666','#996666','#993333','#660000',
-''); // 󔒂Ƃ̗vf̓XLbv.
-
+ "#ffffff",
+ "#ffe6e6",
+ "#ffcccc",
+ "#ff9999",
+ "#e6cccc",
+ "#e69999",
+ "#cc9999",
+ "#cc6666",
+ "#996666",
+ "#993333",
+ "#660000",
+ ""
+); // 󔒂Ƃ̗vf̓XLbv.
// ftHg̃pbgJ[ (ԍŏɃAvbgɂłF)
-var pbase = '#000000\n#FFFFFF\n#B47575\n#888888\n#FA9696\n#C096C0\n#FFB6FF\n#8080FF\n#25C7C9\n#E7E58D\n#E7962D\n#99CB7B\n#FCECE2\n#F9DDCF';
-
+var pbase =
+ "#000000\n#FFFFFF\n#B47575\n#888888\n#FA9696\n#C096C0\n#FFB6FF\n#8080FF\n#25C7C9\n#E7E58D\n#E7962D\n#99CB7B\n#FCECE2\n#F9DDCF";
// TvJ[
- // \pbg̃J[ԍ(̒ɂԍŏo)
-var sams = new Array(0,2,4,6,8,10,12,1,3,5,7,9,11,13); // ʓx+xɂƂ
-var samx = new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13); // Fŏz‚Ƃ
+// \pbg̃J[ԍ(̒ɂԍŏo)
+var sams = new Array(0, 2, 4, 6, 8, 10, 12, 1, 3, 5, 7, 9, 11, 13); // ʓx+xɂƂ
+var samx = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13); // Fŏz‚Ƃ
-selfv[1] = '&nbsp;'; // tHg
+selfv[1] = "&nbsp;"; // tHg
selfv[2] = 'style="font-size:xx-small; background-color:$FONT;"';
- // tHg^O̒g(u$FONTv:16i@RGBFAmɓKp鑮́3)
- // c color, style="color" style="background", style="background-color")
+// tHg^O̒g(u$FONTv:16i@RGBFAmɓKp鑮́3)
+// c color, style="color" style="background", style="background-color")
- // 艺 ">"(‚^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ɖ߂"><br>\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{"><br>\n'; // RGB+
-selfv[17] = 'value="RGB-" title="pbgŜRGB|"><br>\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ɖ߂"><br>\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{"><br>\n'; // RGB+
+selfv[17] = 'value="RGB-" title="pbgŜRGB|"><br>\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<br>\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|)"><br>\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<br>\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|)"><br>\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[ɕۑ"><br>\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[ɕۑ"><br>\n'; // Z[u
// ftHg̃pbg F360ɂ邩Aʓx++x-- ɂ邩
-selfv[28] = 'style="border-width:0;" title="ftHg̃pbǵAFŏz‚">H<sup>o</sup>'; // H
-selfv[29] = 'style="border-width:0;" title="ftHg̃pbǵAʓx{Ax|ŃXg">+S-B'; // +S-B
-selfv[30] = 'value="X" title="Ŝ̃pbgftHgɖ߂"><br>\n'; // ftHg
-
+selfv[28] =
+ 'style="border-width:0;" title="ftHg̃pbǵAFŏz‚">H<sup>o</sup>'; // H
+selfv[29] =
+ 'style="border-width:0;" title="ftHg̃pbǵAʓx{Ax|ŃXg">+S-B'; // +S-B
+selfv[30] = 'value="X" title="Ŝ̃pbgftHgɖ߂"><br>\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"><br>\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"><br>\n'; //
// ̃pbge[u͂łA\[XƂ^OƂ (form^O͏_)
// tH[n܂
-selfytag[0] = '<table class="ptable"><tr><form name="palepale"><td class="ptd" nowrap>\n<div align=right class="menu">Palette-Selfy</div>\n<div style="font-size:xx-small;">\n';
+selfytag[0] =
+ '<table class="ptable"><tr><form name="palepale"><td class="ptd" nowrap>\n<div align=right class="menu">Palette-Selfy</div>\n<div style="font-size:xx-small;">\n';
// tH[̊_1 (•ʂ̃pbg ` Ŝ HSBARGB +- Ƃ)
selfytag[1] = '<div style="text-align:right; padding:5;">\n';
// tH[̊_2 (Ŝ HSBARGB +- Ƃ ` Of[V)
-selfytag[2] = '</div>\n<div style="text-align:right; padding:0 5 5 5;"">\nGradation';
+selfytag[2] =
+ '</div>\n<div style="text-align:right; padding:0 5 5 5;"">\nGradation';
// tH[̊_3 (Of[V ` pbg̒ljE폜{^)
-selfytag[3] = '</div>\n<div style="text-align:right; padding:0 5 0 5;"">\nPalette';
+selfytag[3] =
+ '</div>\n<div style="text-align:right; padding:0 5 0 5;"">\nPalette';
// tH[̊_4 (pbg̒ljE폜{^ ` Z[u{^)
-selfytag[4] = '\nSave';
+selfytag[4] = "\nSave";
// tH[̊_5 (Z[u{^ ` Default H++/+S-B ǂ炩)
-selfytag[5] = '</div>\n<div style="text-align:right; padding:3 5 2 5;"">\nDefault';
+selfytag[5] =
+ '</div>\n<div style="text-align:right; padding:3 5 2 5;"">\nDefault';
// tH[̊_6 (Default H++/+S-B ǂ炩 ` pbg̃Abv/_E[h)
-selfytag[6] = '</div>\n<div style="text-align:right; padding:0 5 0 5;">\nUpdata ';
+selfytag[6] =
+ '</div>\n<div style="text-align:right; padding:0 5 0 5;">\nUpdata ';
// tH[I
-selfytag[7] = '</div>\n</div>\n</td></form></tr></table>\n';
+selfytag[7] = "</div>\n</div>\n</td></form></tr></table>\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 = '<input type="button" '; // input-button
-var inr = '<input type="radio" '; // input-button
-var cname = 'selfy='; // cookie-name
-var psx_ch = new Array('',''); // h_sb-checked
-var brwz=0;
-if(d.all){ brwz=1; }else if(d.getElementById){ brwz=2; }
-
+var pon, pno; // radio`FbNH / `FbNpbgNO.
+var qon, qno, qmo; // buttonvbVH / vbVpbgNO.
+var pals = new Array(); // color-palette
+var inp = '<input type="button" '; // input-button
+var inr = '<input type="radio" '; // input-button
+var cname = "selfy="; // cookie-name
+var psx_ch = new Array("", ""); // h_sb-checked
+var brwz = 0;
+if (d.all) {
+ brwz = 1;
+} else if (d.getElementById) {
+ brwz = 2;
+}
// -------------------------------------------------------------------------
// HSBRGB vZ. l0`255.
-function HSBtoRGB(h,s,v){
- var r,g,b;
- if(s==0){
- r=v; g=v; b=v;
- }else{
- var max,min,dif;
- h*=360/255; //360
- max=v;
- dif=v*s/255; //s=(dif/max)*255
- min=v-dif; //min=max-dif
-
- if(h<60){
- r=max; b=min; g=h*dif/60+min;
- }else if(h<120){
- g=max; b=min; r=-(h-120)*dif/60+min;
- }else if(h<180){
- g=max; r=min; b= (h-120)*dif/60+min;
- }else if(h<240){
- b=max; r=min; g=-(h-240)*dif/60+min;
- }else if(h<300){
- b=max; g=min; r= (h-240)*dif/60+min;
- }else if(h<=360){
- r=max; g=min; b=-(h-360)*dif/60+min;
- }else{r=0;g=0;b=0;}
- }
- return(new Array(r,g,b));
+function HSBtoRGB(h, s, v) {
+ var r, g, b;
+ if (s == 0) {
+ r = v;
+ g = v;
+ b = v;
+ } else {
+ var max, min, dif;
+ h *= 360 / 255; //360
+ max = v;
+ dif = (v * s) / 255; //s=(dif/max)*255
+ min = v - dif; //min=max-dif
+
+ if (h < 60) {
+ r = max;
+ b = min;
+ g = (h * dif) / 60 + min;
+ } else if (h < 120) {
+ g = max;
+ b = min;
+ r = (-(h - 120) * dif) / 60 + min;
+ } else if (h < 180) {
+ g = max;
+ r = min;
+ b = ((h - 120) * dif) / 60 + min;
+ } else if (h < 240) {
+ b = max;
+ r = min;
+ g = (-(h - 240) * dif) / 60 + min;
+ } else if (h < 300) {
+ b = max;
+ g = min;
+ r = ((h - 240) * dif) / 60 + min;
+ } else if (h <= 360) {
+ r = max;
+ g = min;
+ b = (-(h - 360) * dif) / 60 + min;
+ } else {
+ r = 0;
+ g = 0;
+ b = 0;
+ }
+ }
+ return new Array(r, g, b);
}
-
// RGBHSB vZ. l0`255.
-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));
+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; 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')));
+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; 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')));
+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; 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')));
+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<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 += '<font id="font_'+p+'_'+k+'" '+cl+' title="'+ctl+'">'+selfv[1]+'</font>';
- }
- 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 +=
+ '<font id="font_' +
+ p +
+ "_" +
+ k +
+ '" ' +
+ cl +
+ ' title="' +
+ ctl +
+ '">' +
+ selfv[1] +
+ "</font>";
+ }
+ return ss;
}
-
// pbg̃Xg
-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+='<font color="'+ps[0]+'" id="font_'+p+'" title="'+ctl+'">'+samw+'</font>';
- 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+='<font color="'+ps[0]+'" id="font_'+p+'" title="'+ctl+'">'+samw+'</font>';
+ 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<slong; i++){
- // color-title
- var k,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];
- }
- // replace
- var ds;
- if(brwz==1){ ds = d.all('font_'+p+'_'+k); }
- else if(brwz==2){ ds = d.getElementById('font_'+p+'_'+k); }
- if(ds){
- if(ds.style.background){ ds.style.background = ps[k]; }
- if(ds.style.backgroundColor){ ds.style.backgroundColor = ps[k]; }
- if(ds.style.color){ ds.style.color = ps[k]; }
- if(ds.color){ ds.color = ps[k]; }
- }
- }
-
- // check
- if(not!=1){
- var df = d.forms.palepale;
- for(var j=0; j<df.rad.length; j++){
- if(df.rad[j].value == p){
- df.rad[j].checked = true; break; }
- }
- }
+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 < slong; i++) {
+ // color-title
+ var k,
+ 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];
+ }
+ // replace
+ var ds;
+ if (brwz == 1) {
+ ds = d.all("font_" + p + "_" + k);
+ } else if (brwz == 2) {
+ ds = d.getElementById("font_" + p + "_" + k);
+ }
+ if (ds) {
+ if (ds.style.background) {
+ ds.style.background = ps[k];
+ }
+ if (ds.style.backgroundColor) {
+ ds.style.backgroundColor = ps[k];
+ }
+ if (ds.style.color) {
+ ds.style.color = ps[k];
+ }
+ if (ds.color) {
+ ds.color = ps[k];
+ }
+ }
+ }
+
+ // check
+ if (not != 1) {
+ var df = d.forms.palepale;
+ for (var j = 0; j < df.rad.length; j++) {
+ if (df.rad[j].value == p) {
+ df.rad[j].checked = true;
+ break;
+ }
+ }
+ }
}
-
// checkO
-function checkout(q){
- pon=0; pno='';
- if(q!=1){ qno=''; qmo=''; qon=0; }
- var df = document.forms.palepale;
- for(var j=0; j<df.rad.length; j++){
- if(df.rad[j].checked == true){
- df.rad[j].checked = false; break; }
- }
+function checkout(q) {
+ pon = 0;
+ pno = "";
+ if (q != 1) {
+ qno = "";
+ qmo = "";
+ qon = 0;
+ }
+ var df = document.forms.palepale;
+ for (var j = 0; j < df.rad.length; j++) {
+ if (df.rad[j].checked == true) {
+ df.rad[j].checked = false;
+ break;
+ }
+ }
}
-
// ȑÕpbgۑ
-function poncheck(not){
- var d = document;
- var df = document.forms.palepale;
- if(df.autosave&&df.autosave.checked==false){ return; }
- else if(pon==1){
- var pget = String(d.paintbbs.getColors());
- if(pals[pno] != pget){
- pals[pno] = pget;
- checkin(pno,1);
- if(not!=1){ pcookset(1); }
- }
- }
+function poncheck(not) {
+ var d = document;
+ var df = document.forms.palepale;
+ if (df.autosave && df.autosave.checked == false) {
+ return;
+ } else if (pon == 1) {
+ var pget = String(d.paintbbs.getColors());
+ if (pals[pno] != pget) {
+ pals[pno] = pget;
+ checkin(pno, 1);
+ if (not != 1) {
+ pcookset(1);
+ }
+ }
+ }
}
-
// pbgZ[u
-function savy(p){
- var d = document;
- pals[p] = String(d.paintbbs.getColors());
- checkin(p);
- pcookset(1);
- pon=1; pno=p;
+function savy(p) {
+ var d = document;
+ pals[p] = String(d.paintbbs.getColors());
+ checkin(p);
+ pcookset(1);
+ pon = 1;
+ pno = p;
}
-
// pbgftHg
-function defy(p){
- checkout();
- var q = pdefs[p];
- var df = document.forms.palepale;
- if(check_h_sb()==1){ q = pdefx[p]; }
- if(q){
- pals[p] = q;
- rady(p,2);
- checkin(p);
- }else{ minsy(p); }
+function defy(p) {
+ checkout();
+ var q = pdefs[p];
+ var df = document.forms.palepale;
+ if (check_h_sb() == 1) {
+ q = pdefx[p];
+ }
+ if (q) {
+ pals[p] = q;
+ rady(p, 2);
+ checkin(p);
+ } else {
+ minsy(p);
+ }
}
-
// pbglj
-function plusy(){
- var d = document;
- if(brwz==1 || brwz==2){
- var p=pals.length;
- var pz = String(d.paintbbs.getColors());
- if(pz){ pals[p] = pz; }
- else{
- pals[p] = '#'+Number(d.paintbbs.getInfo().m.iColor).toString(16);
- rady(p,1);
- }
- }
- if(brwz==1 && d.all('palelist').innerHTML){
- d.all('palelist').innerHTML = palette_list();
- checkin(p);
- }else if(brwz==2 && d.getElementById('palelist').innerHTML){
- d.getElementById('palelist').innerHTML = palette_list();
- checkin(p);
- }
+function plusy() {
+ var d = document;
+ if (brwz == 1 || brwz == 2) {
+ var p = pals.length;
+ var pz = String(d.paintbbs.getColors());
+ if (pz) {
+ pals[p] = pz;
+ } else {
+ pals[p] = "#" + Number(d.paintbbs.getInfo().m.iColor).toString(16);
+ rady(p, 1);
+ }
+ }
+ if (brwz == 1 && d.all("palelist").innerHTML) {
+ d.all("palelist").innerHTML = palette_list();
+ checkin(p);
+ } else if (brwz == 2 && d.getElementById("palelist").innerHTML) {
+ d.getElementById("palelist").innerHTML = palette_list();
+ checkin(p);
+ }
}
-
// pbg폜
-function minsy(p){
- var d = document;
- var df = d.forms.palepale;
- if(!p&&p!=0){
- for(var j=0; j<=df.rad.length; j++){
- if(df.rad[j] && df.rad[j].checked==true){p=Number(df.rad[j].value); break; }
- }
- }
- if((!p&&p!=0)||p<0){ return; }
- pals[p] = '';
- var plong = pdefs.length;
- if(check_h_sb()==1){ plong = pdefx.length; }
- if(p>=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();
+function minsy(p) {
+ var d = document;
+ var df = d.forms.palepale;
+ if (!p && p != 0) {
+ for (var j = 0; j <= df.rad.length; j++) {
+ if (df.rad[j] && df.rad[j].checked == true) {
+ p = Number(df.rad[j].value);
+ break;
+ }
+ }
+ }
+ if ((!p && p != 0) || p < 0) {
+ return;
+ }
+ pals[p] = "";
+ var plong = pdefs.length;
+ if (check_h_sb() == 1) {
+ plong = pdefx.length;
+ }
+ if (p >= 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; p<plong; p++){
- if(psy==1){ pals[p]=pdefx[p]; }else{ pals[p]=pdefs[p]; }
- }
- for (var p=0; p<pals.length; p++){ if(pals[p]){ rady(p,1); } }
-
- 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();
- }else{
- for (var p=0; p<pals.length; p++){
- if(pals[p]){ checkin(p,1); }
- }
- }
+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; p < plong; p++) {
+ if (psy == 1) {
+ pals[p] = pdefx[p];
+ } else {
+ pals[p] = pdefs[p];
+ }
+ }
+ for (var p = 0; p < pals.length; p++) {
+ if (pals[p]) {
+ rady(p, 1);
+ }
+ }
+
+ 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();
+ } else {
+ for (var p = 0; p < pals.length; p++) {
+ if (pals[p]) {
+ checkin(p, 1);
+ }
+ }
+ }
}
-
// ftHg h_sb ̃tH[̃`FbN. HɃ`FbN‚ĂȂ1
-function check_h_sb(lst){
- var ch = 0;
- var df = document.forms.palepale;
- if(lst!=1 && df && df.h_sb){
- for (var i=0; i<df.h_sb.length; i++){
- if(df.h_sb[i].value==1 && df.h_sb[i].checked==true){ ch=1; break; }
- }
- }else{ ch=psx; }
- return ch;
+function check_h_sb(lst) {
+ var ch = 0;
+ var df = document.forms.palepale;
+ if (lst != 1 && df && df.h_sb) {
+ for (var i = 0; i < df.h_sb.length; i++) {
+ if (df.h_sb[i].value == 1 && df.h_sb[i].checked == true) {
+ ch = 1;
+ break;
+ }
+ }
+ } else {
+ ch = psx;
+ }
+ return ch;
}
-
// pbgf[^ Abv[h
-function pupload(){
- var d = document;
- var df = d.forms.palepale;
- var qs = new Array();
- var palx='';
- if(df.palz){ palx = df.palz.value; }
- if(!palx){ return; }
- pals = new Array();
- if(eval(palx)){}
- else{
- var px = palx.split(/\(|\)/);
- var ps = px[1].split(',');
- for (var p=0; p<ps.length; p++){
- var q=ps[p].replace(/[^0-9a-fA-F]/g,''); pals[p] = q;
- }
- }
-
- for (var p=0; p<pals.length; p++){ if(pals[p]){ rady(p,1); } }
-
- 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();
- }else{
- for (var p=0; p<pals.length; p++){
- if(pals[p]){ checkin(p,1); }
- }
- }
+function pupload() {
+ var d = document;
+ var df = d.forms.palepale;
+ var qs = new Array();
+ var palx = "";
+ if (df.palz) {
+ palx = df.palz.value;
+ }
+ if (!palx) {
+ return;
+ }
+ pals = new Array();
+ if (eval(palx)) {
+ } else {
+ var px = palx.split(/\(|\)/);
+ var ps = px[1].split(",");
+ for (var p = 0; p < ps.length; p++) {
+ var q = ps[p].replace(/[^0-9a-fA-F]/g, "");
+ pals[p] = q;
+ }
+ }
+
+ for (var p = 0; p < pals.length; p++) {
+ if (pals[p]) {
+ rady(p, 1);
+ }
+ }
+
+ 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();
+ } else {
+ for (var p = 0; p < pals.length; p++) {
+ if (pals[p]) {
+ checkin(p, 1);
+ }
+ }
+ }
}
-
// pbgf[^ _E[h
-function pdownload(){
- var d = document;
- var df = d.forms.palepale;
- var qs = new Array();
- for (var p=0; p<pals.length; p++){
- qs[p] = "\'"+pals[p].replace(/\n/g,'\\n')+"\'";
- }
- var palx = 'pals = new Array(\n' + qs.join('\,\n') + '\n);';
- if(df.palz){ df.palz.value = palx; }
+function pdownload() {
+ var d = document;
+ var df = d.forms.palepale;
+ var qs = new Array();
+ for (var p = 0; p < pals.length; p++) {
+ qs[p] = "'" + pals[p].replace(/\n/g, "\\n") + "'";
+ }
+ var palx = "pals = new Array(\n" + qs.join(",\n") + "\n);";
+ if (df.palz) {
+ df.palz.value = palx;
+ }
}
-
// Ŝ̃pbgNbL[ɃZ[u
-function pcookset(o){
- var df = document.forms.palepale;
- if(o&&df.autosave&&df.autosave.checked==false){ return; }
- var exp=new Date();
- exp.setTime(exp.getTime()+1000*86400*60);
- var cs = new Array();
- for(var i=0; i<pals.length; i++){
- cs[i] = escape(pals[i].replace(/\n/g,'_'));
- }
- var cooki = '';
- if(df.num){ cooki += df.num.value; }
- cooki += '_'+check_h_sb()+'_%00';
- cooki += cs.join('%00');
- document.cookie = cname + cooki + "; expires=" + exp.toGMTString();
+function pcookset(o) {
+ var df = document.forms.palepale;
+ if (o && df.autosave && df.autosave.checked == false) {
+ return;
+ }
+ var exp = new Date();
+ exp.setTime(exp.getTime() + 1000 * 86400 * 60);
+ var cs = new Array();
+ for (var i = 0; i < pals.length; i++) {
+ cs[i] = escape(pals[i].replace(/\n/g, "_"));
+ }
+ var cooki = "";
+ if (df.num) {
+ cooki += df.num.value;
+ }
+ cooki += "_" + check_h_sb() + "_%00";
+ cooki += cs.join("%00");
+ document.cookie = cname + cooki + "; expires=" + exp.toGMTString();
}
-
// Ŝ̃pbgNbL[烍[h
-function pcookget(){
- var cooks = document.cookie.split("; ");
- var cooki = '';
- for (var i=0; i<cooks.length; i++){
- if (cooks[i].substr(0,cname.length) == cname){
- cooki = cooks[i].substr(cname.length,cooks[i].length);
- break;
- }
- }
- if(cooki){
- var cs = cooki.split('%00');
- pals = new Array();
- for(var i=0; i<cs.length-1; i++){
- pals[i] = unescape(cs[(i+1)]).replace(/\_/g,"\n");
- }
- if(cs[0]){
- var ps = cs[0].split('_');
- if(ps[0]){ pnum = ps[0]; }
- if(ps[1]){ psx = ps[1]; }else if(!ps[1]&&ps[1]==0){ psx=0; }
- }
- }
+function pcookget() {
+ var cooks = document.cookie.split("; ");
+ var cooki = "";
+ for (var i = 0; i < cooks.length; i++) {
+ if (cooks[i].substr(0, cname.length) == cname) {
+ cooki = cooks[i].substr(cname.length, cooks[i].length);
+ break;
+ }
+ }
+ if (cooki) {
+ var cs = cooki.split("%00");
+ pals = new Array();
+ for (var i = 0; i < cs.length - 1; i++) {
+ pals[i] = unescape(cs[i + 1]).replace(/\_/g, "\n");
+ }
+ if (cs[0]) {
+ var ps = cs[0].split("_");
+ if (ps[0]) {
+ pnum = ps[0];
+ }
+ if (ps[1]) {
+ psx = ps[1];
+ } else if (!ps[1] && ps[1] == 0) {
+ psx = 0;
+ }
+ }
+ }
}
-
// 鐔𑝂₵茸炵
-function num_plus(n){
- var df = document.forms.palepale;
- var m = Number(df.num.value); var l=n;
- n *= Math.abs(Math.round(m/10))+1; if(n==0){ n=l; }
- df.num.value = m+n;
+function num_plus(n) {
+ var df = document.forms.palepale;
+ var m = Number(df.num.value);
+ var l = n;
+ n *= Math.abs(Math.round(m / 10)) + 1;
+ if (n == 0) {
+ n = l;
+ }
+ df.num.value = m + n;
}
-
// g[ZNg̒l}
-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);
+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<plong; p++){
- if(psx==1){ pals[p]=pdefx[p]; }else{ pals[p]=pdefs[p]; }
- if(pzs && pzs.length>=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<small>&nbsp;</small>+-');
- d.write('<input type="text" name="num" value="'+pnum+'" '+selfv[0]);
- d.write(inp+'value="+" onclick="num_plus(1)">');
- d.write(inp+'value="-" onclick="num_plus(-1)">\n');
- }
- // pbgXg
- if(pdefs||pdefx) d.write('<div id="palelist">\n'+palette_list(1)+'</div>\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 <select name="tone" onchange="tone_sel(this.value)">');
- for (var i=0; i<=100; i+=5){
- d.write('<option value="'+i+'">'+i+'%</option>\n'); if(i>=10){i+=5;}
- }
- d.write('</select>');
- 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('<input type="checkbox" name="autosave" value="1" '+selfv[26]); //26
- if(selfv[27]) d.write(inp+'onclick="pcookset()" ' +selfv[27]); //27
-
- // ftHg
- if(selfytag[5]) d.write(selfytag[5]);
- if(selfv[28]) d.write(inr+'name="h_sb" value="1" ' +psx_ch[1]+selfv[28]); //28
- if(selfv[29]) d.write(inr+'name="h_sb" value="0" ' +psx_ch[0]+selfv[29]); //29
- if(selfv[30]) d.write(inp+'onclick="def_list()" ' +selfv[30]); //30
-
- // UPLOAD / DOWNLOAD
- if(selfytag[6]) d.write(selfytag[6]);
- if(selfv[31]) d.write('<input type="text" name="palz" '+selfv[31]); //31
- if(selfv[32]) d.write(inp+'onclick="pupload()" ' +selfv[32]); //32
- if(selfv[33]) d.write(inp+'onclick="pdownload()" ' +selfv[33]); //33
-
- // /FORM
- if(selfytag[7]) d.write(selfytag[7]);
+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 < plong; p++) {
+ if (psx == 1) {
+ pals[p] = pdefx[p];
+ } else {
+ pals[p] = pdefs[p];
+ }
+ if (pzs && pzs.length >= 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<small>&nbsp;</small>+-");
+ d.write('<input type="text" name="num" value="' + pnum + '" ' + selfv[0]);
+ d.write(inp + 'value="+" onclick="num_plus(1)">');
+ d.write(inp + 'value="-" onclick="num_plus(-1)">\n');
+ }
+ // pbgXg
+ if (pdefs || pdefx)
+ d.write('<div id="palelist">\n' + palette_list(1) + "</div>\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 <select name="tone" onchange="tone_sel(this.value)">');
+ for (var i = 0; i <= 100; i += 5) {
+ d.write('<option value="' + i + '">' + i + "%</option>\n");
+ if (i >= 10) {
+ i += 5;
+ }
+ }
+ d.write("</select>");
+ 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('<input type="checkbox" name="autosave" value="1" ' + selfv[26]); //26
+ if (selfv[27]) d.write(inp + 'onclick="pcookset()" ' + selfv[27]); //27
+
+ // ftHg
+ if (selfytag[5]) d.write(selfytag[5]);
+ if (selfv[28])
+ d.write(inr + 'name="h_sb" value="1" ' + psx_ch[1] + selfv[28]); //28
+ if (selfv[29])
+ d.write(inr + 'name="h_sb" value="0" ' + psx_ch[0] + selfv[29]); //29
+ if (selfv[30]) d.write(inp + 'onclick="def_list()" ' + selfv[30]); //30
+
+ // UPLOAD / DOWNLOAD
+ if (selfytag[6]) d.write(selfytag[6]);
+ if (selfv[31]) d.write('<input type="text" name="palz" ' + selfv[31]); //31
+ if (selfv[32]) d.write(inp + 'onclick="pupload()" ' + selfv[32]); //32
+ if (selfv[33]) d.write(inp + 'onclick="pdownload()" ' + selfv[33]); //33
+
+ // /FORM
+ if (selfytag[7]) d.write(selfytag[7]);
}
diff --git a/static/js/shobon.js b/static/js/shobon.js
index fdc0b58..e7a9073 100644
--- a/static/js/shobon.js
+++ b/static/js/shobon.js
@@ -1,5 +1,5 @@
var are_filters = false;
-var hide_word = new Set()
+var hide_word = new Set();
var hide_name = new Set();
var hide_id = new Set();
@@ -9,7 +9,7 @@ function shobon() {
var where = document.body.classList;
var inThread = where.contains("threadpage");
- if(!inThread) {
+ if (!inThread) {
/* Create settings link */
var box = document.getElementsByClassName("links")[0];
box.appendChild(document.createTextNode(" | "));
@@ -20,28 +20,32 @@ function shobon() {
box.appendChild(slnk);
}
- if(localStorage.getItem("shobon_on") == "false") return;
+ if (localStorage.getItem("shobon_on") == "false") return;
else console.log("Running shobon " + shobon_ver);
-
+
var newRepliesCounter = 0;
-
+
// dejar barra superior fija
- if(localStorage.getItem("shobon_navbar") == "true") {
+ if (localStorage.getItem("shobon_navbar") == "true") {
fixedNav();
}
- var shobon_time = localStorage.getItem("shobon_time");
- if(shobon_time != "false") {
- if (boardName == "world") week = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
- else if (boardName == "2d") week = ["日", "月", "火", "水", "木", "金", "土"];
+ var shobon_time = localStorage.getItem("shobon_time");
+ if (shobon_time != "false") {
+ if (boardName == "world")
+ week = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
+ else if (boardName == "2d")
+ week = ["日", "月", "火", "水", "木", "金", "土"];
else week = ["dom", "lun", "mar", "mie", "jue", "vie", "sab"];
}
- if(where=="threads") {
- if(shobon_time != "false") {
+ if (where == "threads") {
+ if (shobon_time != "false") {
var dt = document.getElementsByClassName("date");
- for (var i=0; i<dt.length; i++) {
- dt[i].addEventListener("mouseover", function(e) { this.title = "Hace "+timeAgo(this.dataset.unix); });
+ for (var i = 0; i < dt.length; i++) {
+ dt[i].addEventListener("mouseover", function(e) {
+ this.title = "Hace " + timeAgo(this.dataset.unix);
+ });
dt[i].textContent = localTime(dt[i].dataset.unix);
}
}
@@ -53,7 +57,7 @@ function shobon() {
}
var threadList = document.getElementsByClassName("thread");
- for (var i=0; i<threadList.length; i++) {
+ for (var i = 0; i < threadList.length; i++) {
var threadId;
var thread = threadList[i];
var replyList = thread.getElementsByClassName("reply");
@@ -64,7 +68,10 @@ function shobon() {
}
var lastReplyN = replyList[replyList.length - 1].attributes["data-n"].value;
- if(localStorage.getItem("shobon_newposts") == "true" && localStorage.getItem(boardName + "_" + threadId) == null) {
+ if (
+ localStorage.getItem("shobon_newposts") == "true" &&
+ localStorage.getItem(boardName + "_" + threadId) == null
+ ) {
localStorage.setItem(boardName + "_" + threadId, lastReplyN);
}
var lastSeen = localStorage.getItem(boardName + "_" + threadId);
@@ -73,39 +80,46 @@ function shobon() {
for (var e = 0; e < replyList.length; e++) {
var reply = replyList[e];
var message = reply.getElementsByClassName("msg")[0];
-
- if(shobon_time != "false") {
+
+ if (shobon_time != "false") {
var date = reply.getElementsByClassName("date")[0];
- date.addEventListener("mouseover", function(e) { this.title = "Hace "+timeAgo(this.dataset.unix); });
- if (date.textContent.includes("ID:")) var id = date.textContent.split(" ")[1];
+ date.addEventListener("mouseover", function(e) {
+ this.title = "Hace " + timeAgo(this.dataset.unix);
+ });
+ if (date.textContent.includes("ID:"))
+ var id = date.textContent.split(" ")[1];
date.textContent = localTime(date.dataset.unix, id);
}
- if(localStorage.getItem("shobon_newposts") == "true") {
+ if (localStorage.getItem("shobon_newposts") == "true") {
var replyId = reply.attributes["data-n"].value;
var isNewReply = parseInt(lastSeen) < parseInt(replyId);
if (isNewReply) {
newRepliesCounter++;
newRepliesInThread++;
- reply.children[0].innerHTML += " <span class='shobonNew' style='color:#CC6666; font-weight:bold;'>Nuevo!</span>";
+ reply.children[0].innerHTML +=
+ " <span class='shobonNew' style='color:#CC6666; font-weight:bold;'>Nuevo!</span>";
}
}
// 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", "<b>Activar extensión</b>", 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", "<b>Activar extensión</b>", 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 + "<span class='uid ID_" + userId.slice(0,-1) + "' style='background-color:#" + idColor + ";color:#" + reverseColor + ";padding:0 3px;border-radius:5px; font-size:0.9em;vertical-align:top;'>ID:" + userId + "</span>";
- dateId.getElementsByClassName("uid")[0].addEventListener("click", markId, false)
+ var lastChar = userId.substring(userId.length - 1, userId.length);
+ dateId.innerHTML =
+ postDate +
+ "<span class='uid ID_" +
+ userId.slice(0, -1) +
+ "' style='background-color:#" +
+ idColor +
+ ";color:#" +
+ reverseColor +
+ ";padding:0 3px;border-radius:5px; font-size:0.9em;vertical-align:top;'>ID:" +
+ userId +
+ "</span>";
+ 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<len; i++) {
+ for (i = 0; i < len; i++) {
var prev = String(sel[0].className);
- sel[0].className = sel[0].className.toString().replace(/ sel/i,"");
+ sel[0].className = sel[0].className.toString().replace(/ sel/i, "");
}
if (currentSel == uid) {
currentSel = null;
@@ -438,38 +516,38 @@ function markId(e) {
}
currentSel = uid;
var tosel = document.getElementsByClassName(uid);
- for(j=0; j<tosel.length; j++) {
+ for (j = 0; j < tosel.length; j++) {
tosel[j].className = tosel[j].className + " sel";
}
}
function embedImg(reply) {
var links = reply.getElementsByTagName("a");
- for(i=0;i<links.length&&i<5;i++) {
+ for (i = 0; i < links.length && i < 5; i++) {
var url = links[i].href;
- if(url.startsWith("https://i.imgur.com")) {
- var ext = url.lastIndexOf('.');
- var thumburl = url.slice(0, ext) + 's' + url.slice(ext);
- } else if(links[i].href.startsWith("https://pbs.twimg.com")) {
+ if (url.startsWith("https://i.imgur.com")) {
+ var ext = url.lastIndexOf(".");
+ var thumburl = url.slice(0, ext) + "s" + url.slice(ext);
+ } else if (links[i].href.startsWith("https://pbs.twimg.com")) {
var thumburl = links[i].href + ":thumb";
} else continue;
var thumb = document.createElement("img");
thumb.src = thumburl;
links[i].appendChild(document.createElement("br"));
- links[i].appendChild(thumb);
+ links[i].appendChild(thumb);
}
}
function toHex(str) {
- var hex = '';
- for (var i=0; i<str.length; i++) {
- hex += '' + (str.charCodeAt(i) + 125).toString(16);
+ var hex = "";
+ for (var i = 0; i < str.length; i++) {
+ hex += "" + (str.charCodeAt(i) + 125).toString(16);
}
return hex;
}
function invertColor(hex) {
- if (hex.indexOf('#') === 0) {
+ if (hex.indexOf("#") === 0) {
hex = hex.slice(1);
}
// convert 3-digit hex to 6-digits.
@@ -477,7 +555,7 @@ function invertColor(hex) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
if (hex.length !== 6) {
- throw new Error('Invalid HEX color.');
+ throw new Error("Invalid HEX color.");
}
// invert color components
var r = (255 - parseInt(hex.slice(0, 2), 16)).toString(16),
@@ -489,13 +567,13 @@ function invertColor(hex) {
function padZero(str, len) {
len = len || 2;
- var zeros = new Array(len).join('0');
+ var zeros = new Array(len).join("0");
return (zeros + str).slice(-len);
}
function fixedNav() {
var bar = document.getElementById("main_nav");
- if(bar) document.body.className+=" fix";
+ if (bar) document.body.className += " fix";
}
-document.addEventListener('DOMContentLoaded', shobon, false); \ No newline at end of file
+document.addEventListener("DOMContentLoaded", shobon, false);
diff --git a/static/js/weabot.js b/static/js/weabot.js
index c379ffc..6557f66 100644
--- a/static/js/weabot.js
+++ b/static/js/weabot.js
@@ -1,14 +1,14 @@
-var style_cookie = 'weabot_style_ib';
+var style_cookie = "weabot_style_ib";
function set_stylesheet(styletitle) {
- var css=document.getElementById("css");
- if(css) {
- css.href="/static/css/" + styletitle.toLowerCase()+".css";
+ var css = document.getElementById("css");
+ if (css) {
+ css.href = "/static/css/" + styletitle.toLowerCase() + ".css";
localStorage.setItem(style_cookie, styletitle);
}
}
-if(style_cookie && localStorage.hasOwnProperty(style_cookie)) {
+if (style_cookie && localStorage.hasOwnProperty(style_cookie)) {
set_stylesheet(localStorage.getItem(style_cookie));
}
@@ -16,64 +16,73 @@ var hiddenthreads = Array();
/* IE/Opera fix, because they need to go learn a book on how to use indexOf with arrays */
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(elt /*, from*/) {
- var len = this.length;
- var from = Number(arguments[1]) || 0;
- from = (from < 0) ? Math.ceil(from) : Math.floor(from);
- if (from < 0) from += len;
- for (; from < len; from++) {
- if (from in this && this[from] === elt) return from;
- }
- return -1;
+ var len = this.length;
+ var from = Number(arguments[1]) || 0;
+ from = from < 0 ? Math.ceil(from) : Math.floor(from);
+ if (from < 0) from += len;
+ for (; from < len; from++) {
+ if (from in this && this[from] === elt) return from;
+ }
+ return -1;
};
}
function postClick(num) {
var sel = window.getSelection().toString();
if (sel) sel = sel.replace(/^/gm, ">") + "\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<cells.length;i++) if(cells[i].className == "reply highlight") cells[i].className = "reply";
- var reply = document.getElementById("reply" + post);
- if(reply) {
- reply.className = "reply highlight";
- var match = /^([^#]*)/.exec(document.location.toString());
- document.location = match[1] + "#" + post;
- }
+ var cells = document.getElementsByClassName("reply");
+ for (var i = 0; i < cells.length; i++)
+ if (cells[i].className == "reply highlight") cells[i].className = "reply";
+ var reply = document.getElementById("reply" + post);
+ if (reply) {
+ reply.className = "reply highlight";
+ var match = /^([^#]*)/.exec(document.location.toString());
+ document.location = match[1] + "#" + post;
+ }
}
function expandimg(e) {
@@ -84,35 +93,42 @@ function expandimg(e) {
var img_h = parseInt(e.dataset.h);
var thumb_w = parseInt(e.dataset.tw);
var thumb_h = parseInt(e.dataset.th);
- var format = img_url.substring(img_url.lastIndexOf(".")+1, img_url.length);
+ var format = img_url.substring(img_url.lastIndexOf(".") + 1, img_url.length);
var exp_vid = 0;
- 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 (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', '<img class="thumbpreview" src="' + read.result + '" /> ' + 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",
+ '<img class="thumbpreview" src="' + read.result + '" /> ' + 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<srt.length;i++) srt[i].innerHTML=srt[i].innerText;
- srt[type].innerHTML = "<b>"+srt[type].innerText+"</b>";
+ for (var i = 0; i < srt.length; i++) srt[i].innerHTML = srt[i].innerText;
+ srt[type].innerHTML = "<b>" + srt[type].innerText + "</b>";
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<arr.length;j++) cont.appendChild(arr[j]);
+ 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 < arr.length; j++) cont.appendChild(arr[j]);
localStorage.setItem("catalog", JSON.stringify(opcs));
}
@@ -280,7 +347,7 @@ function catTeasers(teaser) {
var style = document.createElement("style");
style.id = "teaser_style";
style.type = "text/css";
- style.innerText = '#catalog p{display:none}';
+ style.innerText = "#catalog p{display:none}";
document.head.appendChild(style);
btn.innerText = "Mostrar";
} else {
@@ -294,37 +361,75 @@ function catTeasers(teaser) {
function catMenu(e) {
var brd = document.getElementsByName("board")[0].value;
var id = this.dataset.id;
- this.insertAdjacentHTML('afterbegin', '<div id="thread_ctrl" style="margin-bottom:3px;">[<a href="/cgi/report/' + brd + '/' + id + '">Denunciar</a>] [<a href="#" class="hh">Ocultar</a>]');
+ this.insertAdjacentHTML(
+ "afterbegin",
+ '<div id="thread_ctrl" style="margin-bottom:3px;">[<a href="/cgi/report/' +
+ brd +
+ "/" +
+ id +
+ '">Denunciar</a>] [<a href="#" class="hh">Ocultar</a>]'
+ );
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', ' <span id="hidden_label">[Hilos ocultos: <span id="hidden_num">' + hidden_num + '</span> - ');
+ menu.insertAdjacentHTML(
+ "beforeend",
+ ' <span id="hidden_label">[Hilos ocultos: <span id="hidden_num">' +
+ hidden_num +
+ "</span> - "
+ );
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<hiddenthreads.length;i++){
- try {document.getElementById("cat" + hiddenthreads[i]).removeAttribute("style");}
- catch(err) { continue; } }
- lbl.parentElement.removeChild(lbl); hidden_num = 0;
+ for (var i = 0; i < hiddenthreads.length; i++) {
+ try {
+ document
+ .getElementById("cat" + hiddenthreads[i])
+ .removeAttribute("style");
+ } catch (err) {
+ continue;
+ }
+ }
+ lbl.parentElement.removeChild(lbl);
+ hidden_num = 0;
var aux = hiddenthreads.join("!");
- var exp = new RegExp("\\b[0-9]+" + document.getElementsByName("board")[0].value + "\\b", "g");
- aux = aux.replace(exp, "!"); aux = aux.replace(/!+/g, "!"); aux = aux.replace(/(^!|!$)/g, "");
- if (aux == "") { localStorage.removeItem("hiddenthreads"); hiddenthreads = []; }
- else { localStorage.setItem("hiddenthreads", aux); hiddenthreads = aux.split("!"); }
+ var exp = new RegExp(
+ "\\b[0-9]+" + document.getElementsByName("board")[0].value + "\\b",
+ "g"
+ );
+ aux = aux.replace(exp, "!");
+ aux = aux.replace(/!+/g, "!");
+ aux = aux.replace(/(^!|!$)/g, "");
+ if (aux == "") {
+ localStorage.removeItem("hiddenthreads");
+ hiddenthreads = [];
+ } else {
+ localStorage.setItem("hiddenthreads", aux);
+ hiddenthreads = aux.split("!");
+ }
});
- lbl.appendChild(shw); lbl.appendChild(document.createTextNode("]"));
+ lbl.appendChild(shw);
+ lbl.appendChild(document.createTextNode("]"));
}
function applyTheme() {
@@ -334,70 +439,87 @@ function applyTheme() {
function readableSize(B) {
var thresh = 1024;
- if(Math.abs(B) < thresh) return B + " B";
- var units = ["KB","MB","GB"];
+ if (Math.abs(B) < thresh) return B + " B";
+ var units = ["KB", "MB", "GB"];
var u = -1;
do {
B /= thresh;
++u;
- } while(Math.abs(B) >= thresh && u < units.length - 1);
- return B.toFixed(1)+" "+units[u];
+ } 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<obj.length; i++){
+ for (var i = 0; i < obj.length; i++) {
var parts = obj[i].childNodes[2].textContent.split(" B, ");
var filesize = parts[0].substring(2);
- obj[i].childNodes[2].textContent = "-(" + readableSize(filesize) + ", " + parts[1];
+ obj[i].childNodes[2].textContent =
+ "-(" + readableSize(filesize) + ", " + parts[1];
}
}
document.addEventListener("DOMContentLoaded", function(e) {
checkhighlight();
- if (localStorage.hasOwnProperty("weabot")) weabot = JSON.parse(localStorage.getItem("weabot"));
- else weabot = {"name":null,"email":null,"password":null};
-
+ if (localStorage.hasOwnProperty("weabot"))
+ weabot = JSON.parse(localStorage.getItem("weabot"));
+ else weabot = { name: null, email: null, password: null };
+
board = document.body.dataset.brd;
var a = document.getElementById("main_nav").getElementsByTagName("a");
- for(var i=0; i<a.length; i++) {
- if (a[i].getAttribute("href") == "/"+board+"/") {a[i].className = "cur_brd"; break;}
+ for (var i = 0; i < a.length; i++) {
+ if (a[i].getAttribute("href") == "/" + board + "/") {
+ a[i].className = "cur_brd";
+ break;
+ }
}
- if (screen.width<720) {
- var head=document.getElementById("main_nav");
- var b=head.getElementsByTagName("a");
- var s=document.createElement("select");
- for(var i=1;i<b.length;i++) {
+ if (screen.width < 720) {
+ var head = document.getElementById("main_nav");
+ var b = head.getElementsByTagName("a");
+ var s = document.createElement("select");
+ for (var i = 1; i < b.length; i++) {
var o = document.createElement("option");
o.value = b[i].href;
o.textContent = b[i].textContent;
- if(b[i].className=="cur_brd") o.defaultSelected = true;
+ if (b[i].className == "cur_brd") o.defaultSelected = true;
s.appendChild(o);
}
- s.addEventListener("change", function(e){ window.location.href=this.value; });
+ s.addEventListener("change", function(e) {
+ window.location.href = this.value;
+ });
head.removeChild(head.childNodes[0]);
head.className = "mob fix";
head.insertBefore(s, head.childNodes[0]);
}
- if(localStorage.hasOwnProperty("hiddenthreads")) {
+ if (localStorage.hasOwnProperty("hiddenthreads")) {
hiddenthreads = localStorage.getItem("hiddenthreads").split("!");
if (document.getElementById("catalog")) {
hidden_num = 0;
- for(var i=0;i<hiddenthreads.length;i++){
+ for (var i = 0; i < hiddenthreads.length; i++) {
try {
- document.getElementById("cat" + hiddenthreads[i]).style.display = "none";
+ document.getElementById("cat" + hiddenthreads[i]).style.display =
+ "none";
hidden_num++;
- } catch(err) { continue; }
+ } catch (err) {
+ continue;
+ }
+ }
+ if (hidden_num) {
+ catHidden();
}
- if (hidden_num) { catHidden(); }
} else {
- for(var i=0;i<hiddenthreads.length;i++){
+ for (var i = 0; i < hiddenthreads.length; i++) {
try {
- document.getElementById("unhide" + hiddenthreads[i]).removeAttribute("style");
- document.getElementById("thread" + hiddenthreads[i]).style.display = "none";
- } catch(err) { continue; }
+ document
+ .getElementById("unhide" + hiddenthreads[i])
+ .removeAttribute("style");
+ document.getElementById("thread" + hiddenthreads[i]).style.display =
+ "none";
+ } catch (err) {
+ continue;
+ }
}
}
}
@@ -416,7 +538,7 @@ document.addEventListener("DOMContentLoaded", function(e) {
postform.file.addEventListener("change", filePreview);
fixFileSize();
}
-
+
var del = document.getElementById("delform");
if (del) del.password.value = weabot.password;
@@ -424,36 +546,62 @@ document.addEventListener("DOMContentLoaded", function(e) {
if (document.getElementById("catalog")) {
srt = document.getElementsByClassName("cat_sort");
- for(var i=0;i<srt.length;i++) { srt[i].innerHTML=srt[i].innerText; srt[i].addEventListener("click", function(e) { e.preventDefault(); opcs.sort=this.dataset.sort; catSort(opcs.sort); }); }
- document.getElementById("cat_size").addEventListener("click", function(e) { e.preventDefault(); opcs.big=!opcs.big; catThumbs(opcs.big); });
- document.getElementById("cat_hide").addEventListener("click", function(e) { e.preventDefault(); opcs.teaser=!opcs.teaser; catTeasers(opcs.teaser); });
+ for (var i = 0; i < srt.length; i++) {
+ srt[i].innerHTML = srt[i].innerText;
+ srt[i].addEventListener("click", function(e) {
+ e.preventDefault();
+ opcs.sort = this.dataset.sort;
+ catSort(opcs.sort);
+ });
+ }
+ document.getElementById("cat_size").addEventListener("click", function(e) {
+ e.preventDefault();
+ opcs.big = !opcs.big;
+ catThumbs(opcs.big);
+ });
+ document.getElementById("cat_hide").addEventListener("click", function(e) {
+ e.preventDefault();
+ opcs.teaser = !opcs.teaser;
+ catTeasers(opcs.teaser);
+ });
document.getElementById("cat_search").addEventListener("keyup", catSearch);
if (localStorage.hasOwnProperty("catalog")) {
opcs = JSON.parse(localStorage.getItem("catalog"));
- if(match=/\?sort=([0-9])/.exec(document.location.toString())) opcs.sort=match[1];
- catSort(opcs.sort); catThumbs(opcs.big); catTeasers(opcs.teaser);
+ if ((match = /\?sort=([0-9])/.exec(document.location.toString())))
+ opcs.sort = match[1];
+ catSort(opcs.sort);
+ catThumbs(opcs.big);
+ catTeasers(opcs.teaser);
} else {
- opcs = {"sort":1,"big":false,"teaser":true}; localStorage.setItem("catalog", JSON.stringify(opcs));
+ opcs = { sort: 1, big: false, teaser: true };
+ localStorage.setItem("catalog", JSON.stringify(opcs));
}
var thr = document.getElementsByClassName("thread");
- for(var i=0;i<thr.length;i++) { thr[i].addEventListener("mouseenter", catMenu); thr[i].addEventListener("mouseleave", catMenuClose); }
+ for (var i = 0; i < thr.length; i++) {
+ thr[i].addEventListener("mouseenter", catMenu);
+ thr[i].addEventListener("mouseleave", catMenuClose);
+ }
}
});
-document.addEventListener("click", function(e) {
- var cn = e.target.className;
- if (cn == "num") {
- e.preventDefault();
- postClick(e.target.textContent);
- return;
- }
- if (cn == "tt") {
- e.preventDefault();
- togglethread(e.target);
- return;
- }
- if (cn == "expimg") {
- e.preventDefault();
- expandimg(e.target);
- return;
- }
-},false); \ No newline at end of file
+document.addEventListener(
+ "click",
+ function(e) {
+ var cn = e.target.className;
+ if (cn == "num") {
+ e.preventDefault();
+ postClick(e.target.textContent);
+ return;
+ }
+ if (cn == "tt") {
+ e.preventDefault();
+ togglethread(e.target);
+ return;
+ }
+ if (cn == "expimg") {
+ e.preventDefault();
+ expandimg(e.target);
+ return;
+ }
+ },
+ false
+);
diff --git a/static/js/weabotxt.js b/static/js/weabotxt.js
index 1301387..ba3e51d 100644
--- a/static/js/weabotxt.js
+++ b/static/js/weabotxt.js
@@ -1,88 +1,102 @@
var style_cookie = "weabot_style_txt";
-if(style_cookie && localStorage.hasOwnProperty(style_cookie)) {
+if (style_cookie && localStorage.hasOwnProperty(style_cookie)) {
set_stylesheet(localStorage.getItem(style_cookie));
}
var hiddenposts = Array();
function set_stylesheet(styletitle) {
- var css=document.getElementById("css");
- if(css) css.href="/static/css/txt/"+styletitle.toLowerCase()+".css";
- localStorage.setItem(style_cookie,styletitle);
+ var css = document.getElementById("css");
+ if (css) css.href = "/static/css/txt/" + styletitle.toLowerCase() + ".css";
+ localStorage.setItem(style_cookie, styletitle);
}
function timeMob(timestamp) {
- var time = Math.round(Date.now()/1000);
+ var time = Math.round(Date.now() / 1000);
var el = time - timestamp;
- if (el<60) return el + "s";
- else if (el<3600) return Math.round(el/60) + "m";
- else if (el<86400) return Math.round(el/3600) + "h";
- else if (el<2628000) return Math.round(el/86400) + "d";
- else if (el<31536000) return Math.round(el/2628000) + "me";
- else return Math.round(el/31557600) + "a";
+ if (el < 60) return el + "s";
+ else if (el < 3600) return Math.round(el / 60) + "m";
+ else if (el < 86400) return Math.round(el / 3600) + "h";
+ else if (el < 2628000) return Math.round(el / 86400) + "d";
+ else if (el < 31536000) return Math.round(el / 2628000) + "me";
+ else return Math.round(el / 31557600) + "a";
}
/* IE/Opera fix, because they need to go learn a book on how to use indexOf with arrays */
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(elt /*, from*/) {
- var len = this.length;
- var from = Number(arguments[1]) || 0;
- from = (from < 0) ? Math.ceil(from) : Math.floor(from);
- if (from < 0) from += len;
- for (; from < len; from++) { if (from in this && this[from] === elt) return from; }
- return -1;
+ var len = this.length;
+ var from = Number(arguments[1]) || 0;
+ from = from < 0 ? Math.ceil(from) : Math.floor(from);
+ if (from < 0) from += len;
+ for (; from < len; from++) {
+ if (from in this && this[from] === elt) return from;
+ }
+ return -1;
};
}
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 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();
- if(typeof preview !== 'undefined') { preview.id = id; preview.addEventListener("click", previewPost); }
- 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();
+ if (typeof preview !== "undefined") {
+ preview.id = id;
+ preview.addEventListener("click", previewPost);
+ }
+ addEventListener("submit", saveInputs);
}
}
}
// Textboard data
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;
}
@@ -90,68 +104,115 @@ function deletePost(e) {
var ids = e.parentElement.firstChild.href.split("/");
var post = ids.pop();
var realid = ids.pop();
- if(confirm("¿Seguro que deseas borrar el mensaje "+post+"?")) {
- var script="/cgi/delete";
- document.location=script+"?board="+board+"&password="+weabot.password+"&delete="+realid;
- }
+ if (confirm("¿Seguro que deseas borrar el mensaje " + post + "?")) {
+ var script = "/cgi/delete";
+ document.location =
+ script +
+ "?board=" +
+ board +
+ "&password=" +
+ weabot.password +
+ "&delete=" +
+ realid;
+ }
}
function postClick(num) {
var sel = window.getSelection().toString();
- if (sel) { sel=sel.replace(/^/gm, ">")+"\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="<em>Cargando...</em>";
+ preview.innerHTML = "<em>Cargando...</em>";
- 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<arr.length;j++) cont.appendChild(arr[j]);
+ 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 < arr.length; j++) cont.appendChild(arr[j]);
localStorage.setItem("threadlist", JSON.stringify(opcs));
}
function listDisplay() {
var d = opcs.disp;
- if (d=="Malla") {
+ if (d == "Malla") {
document.getElementById("header").style.display = "none";
document.getElementById("content").className = "grid";
var style = document.createElement("style");
style.id = "labels";
style.type = "text/css";
- style.textContent = '#content .row div.date{display:none}#content.grid div.com:before{content:"("}#content.grid .com:after{content:")"}';
+ style.textContent =
+ '#content .row div.date{display:none}#content.grid div.com:before{content:"("}#content.grid .com:after{content:")"}';
document.head.appendChild(style);
- } else if (d=="Lista") {
+ } else if (d == "Lista") {
var style = document.getElementById("labels");
if (style) style.parentNode.removeChild(style);
document.getElementById("header").removeAttribute("style");
@@ -163,24 +224,32 @@ function listDisplay() {
function searchSubjects(e) {
var filter = this.value.toLowerCase();
var nodes = document.getElementsByClassName("thread");
- for (i=0; i<nodes.length; i++) {
- if (nodes[i].textContent.toLowerCase().includes(filter)) nodes[i].parentNode.removeAttribute("style");
+ for (i = 0; i < nodes.length; i++) {
+ if (nodes[i].textContent.toLowerCase().includes(filter))
+ nodes[i].parentNode.removeAttribute("style");
else nodes[i].parentNode.style.display = "none";
}
}
function get_xmlhttp() {
- var xmlhttp;
- try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
- catch(e1) {
- try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
- catch(e1) { xmlhttp=null; }
- }
- if(!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest();
- return(xmlhttp);
+ var xmlhttp;
+ try {
+ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e1) {
+ try {
+ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e1) {
+ xmlhttp = null;
+ }
+ }
+ if (!xmlhttp && typeof XMLHttpRequest != "undefined")
+ xmlhttp = new XMLHttpRequest();
+ return xmlhttp;
}
-function is_ie() { return(document.all&&!document.opera); }
+function is_ie() {
+ return document.all && !document.opera;
+}
function showpost(post) {
post.children[0].classList.remove("hidden");
@@ -194,47 +263,54 @@ function togglepost(e) {
e.preventDefault();
var post = this.parentElement;
var postid = board + this.getElementsByClassName("date")[0].dataset.unix;
- if(post.children[1].style.display == 'none') {
+ if (post.children[1].style.display == "none") {
showpost(post);
- if(hiddenposts.includes(postid)) hiddenposts.splice(hiddenposts.indexOf(postid), 1);
+ if (hiddenposts.includes(postid))
+ hiddenposts.splice(hiddenposts.indexOf(postid), 1);
} else {
hidepost(post);
- if(!hiddenposts.includes(postid)) hiddenposts.push(postid);
+ if (!hiddenposts.includes(postid)) hiddenposts.push(postid);
}
localStorage.setItem("hiddenposts", hiddenposts.join("!"));
}
-function applyTheme(){
+function applyTheme() {
var newTheme = document.getElementById("styles").value;
set_stylesheet(newTheme);
}
document.addEventListener("DOMContentLoaded", function() {
- if (localStorage.hasOwnProperty("weabot")) weabot = JSON.parse(localStorage.getItem("weabot"));
- else weabot = {"name":null,"email":null,"password":null};
+ if (localStorage.hasOwnProperty("weabot"))
+ weabot = JSON.parse(localStorage.getItem("weabot"));
+ else weabot = { name: null, email: null, password: null };
board = document.body.dataset.brd;
var head = document.getElementById("main_nav");
if (head) {
var b = head.getElementsByTagName("a");
- for(var i=0; i<b.length; i++) {
- if (b[i].getAttribute("href") == "/"+board+"/") { b[i].className = "cur_brd"; break; }
+ for (var i = 0; i < b.length; i++) {
+ if (b[i].getAttribute("href") == "/" + board + "/") {
+ b[i].className = "cur_brd";
+ break;
+ }
}
}
var dt = document.getElementsByClassName("date");
- if (screen.width<720) {
- if(head) {
- var b=head.getElementsByTagName("a");
- var s=document.createElement("select");
- for(var i=1;i<b.length;i++) {
+ if (screen.width < 720) {
+ if (head) {
+ var b = head.getElementsByTagName("a");
+ var s = document.createElement("select");
+ for (var i = 1; i < b.length; i++) {
var o = document.createElement("option");
o.value = b[i].href;
o.textContent = b[i].textContent;
- if(b[i].className=="cur_brd") o.defaultSelected = true;
+ if (b[i].className == "cur_brd") o.defaultSelected = true;
s.appendChild(o);
}
- s.addEventListener("change", function(e){ window.location.href=this.value; });
+ s.addEventListener("change", function(e) {
+ window.location.href = this.value;
+ });
head.innerHTML = '<a href="/" target="_top">Bienvenido a Internet</a> | ';
head.appendChild(s);
head.removeAttribute("style");
@@ -242,16 +318,19 @@ document.addEventListener("DOMContentLoaded", function() {
var head2 = document.getElementById("thread_nav");
if (head2) head2.removeChild(head2.childNodes[1]);
}
-
- for(var i=0;i<dt.length;i++) {
+
+ for (var i = 0; i < dt.length; i++) {
t = dt[i].textContent;
- if(t.includes("ID:")) var id=t.split(" ")[1]; else id="";
- dt[i].textContent="Hace "+timeMob(dt[i].dataset.unix)+" "+id;
+ if (t.includes("ID:")) var id = t.split(" ")[1];
+ else id = "";
+ dt[i].textContent = "Hace " + timeMob(dt[i].dataset.unix) + " " + id;
}
}
var forms = document.getElementsByTagName("form");
- for(var i=0;i<forms.length;i++) { if(forms[i].id.startsWith("postform")) setInputs(forms[i].id); }
+ for (var i = 0; i < forms.length; i++) {
+ if (forms[i].id.startsWith("postform")) setInputs(forms[i].id);
+ }
var styleSelect = document.getElementById("styles");
if (styleSelect) {
@@ -261,35 +340,57 @@ document.addEventListener("DOMContentLoaded", function() {
if (document.body.classList.contains("threads")) {
var srt = document.getElementsByClassName("l_s");
- for(var i=0;i<srt.length;i++){ srt[i].addEventListener("click",function(e){ e.preventDefault(); opcs.sort=this.textContent; listSort(); }); }
+ for (var i = 0; i < srt.length; i++) {
+ srt[i].addEventListener("click", function(e) {
+ e.preventDefault();
+ opcs.sort = this.textContent;
+ listSort();
+ });
+ }
var dsp = document.getElementsByClassName("l_d");
- for(var i=0;i<dsp.length;i++){ dsp[i].addEventListener("click",function(e){ e.preventDefault(); opcs.disp=this.textContent; listDisplay(); }); }
+ for (var i = 0; i < dsp.length; i++) {
+ dsp[i].addEventListener("click", function(e) {
+ e.preventDefault();
+ opcs.disp = this.textContent;
+ listDisplay();
+ });
+ }
document.getElementById("l_sr").addEventListener("keyup", searchSubjects);
- if (localStorage.hasOwnProperty("threadlist")) { opcs = JSON.parse(localStorage.getItem("threadlist")); listSort(); listDisplay(); }
- else { opcs = {"sort":"Normal","disp":"Lista"}; localStorage.setItem("threadlist", JSON.stringify(opcs)); }
+ if (localStorage.hasOwnProperty("threadlist")) {
+ opcs = JSON.parse(localStorage.getItem("threadlist"));
+ listSort();
+ listDisplay();
+ } else {
+ opcs = { sort: "Normal", disp: "Lista" };
+ localStorage.setItem("threadlist", JSON.stringify(opcs));
+ }
}
- if(localStorage.hasOwnProperty("hiddenposts"))
+ if (localStorage.hasOwnProperty("hiddenposts"))
hiddenposts = localStorage.getItem("hiddenposts").split("!");
- for(var i=0;i<dt.length;i++) {
- if(hiddenposts.includes(board+dt[i].dataset.unix)) {
+ for (var i = 0; i < dt.length; i++) {
+ if (hiddenposts.includes(board + dt[i].dataset.unix)) {
console.log(dt[i].dataset.unix);
hidepost(dt[i].parentElement.parentElement);
}
dt[i].parentElement.addEventListener("dblclick", togglepost);
}
});
-document.addEventListener("click", function(e) {
- var txt = e.target.textContent;
- if (e.target.className == "num") {
- e.preventDefault();
- postClick(txt);
- return;
- }
- if (txt == "del") {
- e.preventDefault();
- deletePost(e.target);
- return;
- }
-},false); \ No newline at end of file
+document.addEventListener(
+ "click",
+ function(e) {
+ var txt = e.target.textContent;
+ if (e.target.className == "num") {
+ e.preventDefault();
+ postClick(txt);
+ return;
+ }
+ if (txt == "del") {
+ e.preventDefault();
+ deletePost(e.target);
+ return;
+ }
+ },
+ false
+);