From 98450fac86ac23f420a3a19e4cefec71c34cc2ee Mon Sep 17 00:00:00 2001 From: moisseev Date: Sun, 3 Dec 2023 16:45:14 +0300 Subject: [WebUI] Refine symbols score input boxes - reduce the minimum number of digits to appear after the decimal from 3 to 2 - remove useless dynamic step - remove useless dynamic min/max restrictions --- interface/js/app/symbols.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'interface') diff --git a/interface/js/app/symbols.js b/interface/js/app/symbols.js index 5c51c28f4..d35715188 100644 --- a/interface/js/app/symbols.js +++ b/interface/js/app/symbols.js @@ -53,10 +53,7 @@ define(["jquery", "app/rspamd", "footable"], server: server }); } - function decimalStep(number) { - const digits = Number(number).toFixed(20).replace(/^-?\d*\.?|0+$/g, "").length; - return (digits === 0 || digits > 4) ? 0.1 : 1.0 / Math.pow(10, digits); - } + function process_symbols_data(data) { const items = []; const lookup = {}; @@ -66,15 +63,12 @@ define(["jquery", "app/rspamd", "footable"], data.forEach((group) => { group.rules.forEach((item) => { - let max = 20; - let min = -20; - if (item.weight > max) { - max = item.weight * 2; - } + const formatter = new Intl.NumberFormat("en", { + minimumFractionDigits: 2, + maximumFractionDigits: 6, + useGrouping: false + }); item.group = group.group; - if (item.weight < min) { - min = item.weight * 2; - } let label_class = ""; if (item.weight < 0) { label_class = "scorebar-ham"; @@ -82,10 +76,8 @@ define(["jquery", "app/rspamd", "footable"], label_class = "scorebar-spam"; } item.weight = ""; if (!item.time) { item.time = 0; -- cgit v1.2.3