aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorLibravatar Renard 2019-04-12 13:48:23 -0400
committerLibravatar Renard 2019-04-12 13:48:23 -0400
commit1496e160da3c6f6cb8742aedced4edefc1211a0b (patch)
tree104262c38546fd41c4f782f49124b0e4c5d07fe5 /static
parent5d42e8c839dd1b56bcf570a0eb286254bfccb53d (diff)
downloadweabot-1496e160da3c6f6cb8742aedced4edefc1211a0b.tar.gz
weabot-1496e160da3c6f6cb8742aedced4edefc1211a0b.tar.xz
weabot-1496e160da3c6f6cb8742aedced4edefc1211a0b.zip
Revirtiendo cambios de shobon a weabot
Shobon no es cargado en el IB, la función fixFileSize es solo para el IB
Diffstat (limited to 'static')
-rw-r--r--static/js/shobon.js25
-rw-r--r--static/js/weabot.js22
2 files changed, 22 insertions, 25 deletions
diff --git a/static/js/shobon.js b/static/js/shobon.js
index e34ee98..8233088 100644
--- a/static/js/shobon.js
+++ b/static/js/shobon.js
@@ -108,10 +108,6 @@ function shobon() {
if(localStorage.getItem("shobon_embedimg") == "true") {
embedImg(reply);
}
- // convertir tamaños de archivo a formato legible
- if(localStorage.getItem("shobon_size") == "true") {
- fixFileSize();
- }
}
if (newRepliesInThread > 0 && !inThread) {
var btnNew = document.createElement("span");
@@ -300,7 +296,6 @@ function shobonSettings(e) {
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_size", "Tamaños de archivo legibles", false));
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));
@@ -448,26 +443,6 @@ function markId(e) {
}
}
-function readableSize(B) {
- var thresh = 1024;
- 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];
-}
-function fixFileSize(){
- var obj = document.getElementsByClassName("fs");
- 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];
- }
-}
-
function embedImg(reply) {
var links = reply.getElementsByTagName("a");
for(i=0;i<links.length&&i<5;i++) {
diff --git a/static/js/weabot.js b/static/js/weabot.js
index 45b7063..428375a 100644
--- a/static/js/weabot.js
+++ b/static/js/weabot.js
@@ -332,6 +332,27 @@ function applyTheme() {
set_stylesheet(newTheme);
}
+function readableSize(B) {
+ var thresh = 1024;
+ 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];
+}
+
+function fixFileSize(){
+ var obj = document.getElementsByClassName("fs");
+ 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];
+ }
+}
+
document.addEventListener("DOMContentLoaded", function(e) {
checkhighlight();
if (localStorage.hasOwnProperty("weabot")) weabot = JSON.parse(localStorage.getItem("weabot"));
@@ -393,6 +414,7 @@ document.addEventListener("DOMContentLoaded", function(e) {
types = document.getElementById("filetypes").innerText.split(", ");
if (types.includes("JPG")) types.push("JPEG");
postform.file.addEventListener("change", filePreview);
+ fixFileSize();
}
var del = document.getElementById("delform");