From: Alexander Moisseev Date: Fri, 10 Jul 2026 14:03:25 +0000 (+0300) Subject: [Fix] WebUI: address jQuery-removal review comments X-Git-Tag: 4.1.3~52^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8bc435c8bcd2e0d63fa7d8722996b5b76114e712;p=thirdparty%2Frspamd.git [Fix] WebUI: address jQuery-removal review comments - stats.js: guard the optional fuzzy_hashes key in addFuzzyStorage (Object.entries/keys of undefined threw on every Status refresh when fuzzy_check was disabled or a neighbour was down), matching the guard addStatfiles already had. - common.js: cancel the hide/show slide animations once the final state is committed, so the fill:"forwards" no longer pins height:0 — a later re-show was measuring the pinned height and animating 0→0. - common.js: treat a single Element (incl. /
, which expose a + // numeric .length — must not be mistaken for a collection. + if (selector.nodeType === 1) return [selector]; if (typeof selector.length === "number") { return Array.from(selector).filter(Boolean); } @@ -454,7 +457,9 @@ define(["nprogress"], } // jQuery fires statusCode handlers once per request for the final - // status, in addition to success/error. + // status, in addition to success/error. Unlike jQuery, which passed + // (jqXHR, textStatus, errorThrown), the handler here is invoked as + // (responseText, statusText, xhr). function runStatusCode() { if (o.statusCode && typeof o.statusCode[xhr.status] === "function") { o.statusCode[xhr.status](xhr.responseText, xhr.statusText, xhr); @@ -638,7 +643,7 @@ define(["nprogress"], queryServer(neighbours_status, 0, "neighbours", { success: function (json) { const [{data}] = json; - if (Object.keys(data).length === 0) { + if (!data || Object.keys(data).length === 0) { ui.neighbours = { local: { host: window.location.host, @@ -696,13 +701,15 @@ define(["nprogress"], if (anim) { const height = el.offsetHeight; el.style.overflow = "hidden"; - el.animate( + const fx = el.animate( [{height: height + "px"}, {height: 0}], {duration: 400, easing: "ease", fill: "forwards"} - ).onfinish = () => { + ); + fx.onfinish = () => { el.classList.add("d-none"); el.style.height = ""; el.style.overflow = ""; + fx.cancel(); }; } else { el.classList.add("d-none"); @@ -722,12 +729,14 @@ define(["nprogress"], const height = el.offsetHeight; // measure natural height now visible el.style.overflow = "hidden"; el.style.height = "0"; - el.animate( + const fx = el.animate( [{height: 0}, {height: height + "px"}], {duration: 400, easing: "ease", fill: "forwards"} - ).onfinish = () => { + ); + fx.onfinish = () => { el.style.height = ""; el.style.overflow = ""; + fx.cancel(); }; } else { el.classList.remove("d-none"); diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 955655bd27..c41cd288e5 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -119,7 +119,8 @@ define(["app/common", "bootstrap", "visibility", stopTimers(); if (id === "#refresh" || id === "#autoRefresh") { - tab_id = "#" + document.querySelector(".nav-link.active").id; + const active = document.querySelector(".nav-link.active"); + if (active) tab_id = "#" + active.id; } document.getElementById("autoRefresh").classList.add("invisible"); @@ -604,7 +605,8 @@ define(["app/common", "bootstrap", "visibility", } else { document.getElementById("learnServers").classList.add("invisible"); } - tabClick("#" + document.querySelector("#tablist > .nav-item > .nav-link.active").id); + const active = document.querySelector("#tablist > .nav-item > .nav-link.active"); + if (active) tabClick("#" + active.id); }); // Radio buttons diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js index 2c2d5d4bb6..0d60f52dac 100644 --- a/interface/js/app/stats.js +++ b/interface/js/app/stats.js @@ -338,9 +338,9 @@ define(["app/common", "d3pie", "d3"], function addFuzzyStorage(server, storages) { let i = 0; const fuzzyTbody = document.querySelector("#fuzzyTable tbody"); - Object.entries(storages).forEach(([storage, hashes]) => { + Object.entries(storages || {}).forEach(([storage, hashes]) => { const serverCell = (i === 0) - ? '' + common.escapeHTML(server) + "" + ? '' + common.escapeHTML(server) + "" : ""; fuzzyTbody.insertAdjacentHTML("beforeend", "" + serverCell + "" + common.escapeHTML(storage) + "" + diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js index 8f1de314a1..3450e92da0 100644 --- a/interface/js/app/upload.js +++ b/interface/js/app/upload.js @@ -28,9 +28,6 @@ define(["app/common", "app/libft"], common.query(url, { data: data, - params: { - processData: false, - }, method: method, headers: headers, success: function (json, jqXHR) { @@ -56,9 +53,6 @@ define(["app/common", "app/libft"], enable_disable_scan_btn(true); common.query("checkv2", { data: data, - params: { - processData: false, - }, method: "POST", headers: scanTextHeaders, success: function (neighbours_status) { @@ -153,9 +147,6 @@ define(["app/common", "app/libft"], common.query("plugins/fuzzy/hashes?flag=" + document.getElementById("fuzzy-flag").value, { data: data, - params: { - processData: false, - }, method: "POST", success: function (neighbours_status) { const json = neighbours_status[0].data;