From 7c83a7e4807b387894abdb4b6edaa92479cc9281 Mon Sep 17 00:00:00 2001
From: Jay
Date: Thu, 11 Apr 2019 02:15:26 -0400
Subject: IB: Moviendo tamaños legibles a shobon y subiendo menú de estilos
De paso no hay que agregar el mismo menú a cada plantilla que el IB tiene.
---
static/js/shobon.js | 26 +++++++++++++++++++++++++-
static/js/weabot.js | 26 +-------------------------
2 files changed, 26 insertions(+), 26 deletions(-)
(limited to 'static/js')
diff --git a/static/js/shobon.js b/static/js/shobon.js
index b9e265c..5c65e94 100644
--- a/static/js/shobon.js
+++ b/static/js/shobon.js
@@ -95,7 +95,10 @@ 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");
@@ -284,6 +287,7 @@ function shobonSettings(e) {
p.appendChild(createCheckbox("shobon_on", "Activar extensión", true));
p.appendChild(createCheckbox("shobon_navbar", "Fijar barra superior", false));
p.appendChild(createCheckbox("shobon_ids", "Colorear IDs", true));
+ p.appendChild(createCheckbox("shobon_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));
@@ -431,6 +435,26 @@ 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= thresh && u < units.length - 1);
- return bytes.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 = " (" + humanFileSize(filesize) + ", " + parts[1];
- }
-}
-
document.addEventListener("DOMContentLoaded", function(e) {
checkhighlight();
if (localStorage.hasOwnProperty("weabot")) weabot = JSON.parse(localStorage.getItem("weabot"));
@@ -399,7 +376,6 @@ 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");
--
cgit v1.2.1-18-gbd029