const icon = $("#theme-icon");
icon.removeClass("fa-moon fa-sun fa-display");
- switch (theme) {
- case "light":
- icon.addClass("fa-sun");
- break;
- case "dark":
- icon.addClass("fa-moon");
- break;
- default:
- icon.addClass("fa-display");
- break;
- }
+ const iconMap = {light: "fa-sun", dark: "fa-moon", auto: "fa-display"};
+ icon.addClass(iconMap[theme] || "fa-display");
}
(function initSettings() {
$("#theme-toggle").on("click", (e) => {
e.preventDefault();
const currentTheme = localStorage.getItem("theme") || "auto";
- // eslint-disable-next-line no-useless-assignment
- let newTheme = null;
-
// Cycle through: light -> dark -> auto -> light
- switch (currentTheme) {
- case "light":
- newTheme = "dark";
- break;
- case "dark":
- newTheme = "auto";
- break;
- default:
- newTheme = "light";
- break;
- }
+ const themeMap = {light: "dark", dark: "auto", auto: "light"};
+ const newTheme = themeMap[currentTheme] || "light";
if (window.rspamd && window.rspamd.theme) {
window.rspamd.theme.applyPreference(newTheme);
function toggleSidebar(side) {
$("#sidebar-" + side).toggleClass("collapsed");
- let contentClass = "col-lg-6";
const openSidebarsCount = $("#sidebar-left").hasClass("collapsed") +
$("#sidebar-right").hasClass("collapsed");
- switch (openSidebarsCount) {
- case 1:
- contentClass = "col-lg-9";
- break;
- case 2:
- contentClass = "col-lg-12";
- break;
- default:
- }
+ const layoutMap = {1: "col-lg-9", 2: "col-lg-12"};
+ const contentClass = layoutMap[openSidebarsCount] || "col-lg-6";
$("#content").removeClass("col-lg-12 col-lg-9 col-lg-6")
.addClass(contentClass);
}
function addStatfiles(server, statfiles) {
$.each(statfiles, (i, statfile) => {
- let cls = "";
- switch (statfile.symbol) {
- case "BAYES_SPAM":
- cls = "symbol-positive";
- break;
- case "BAYES_HAM":
- cls = "symbol-negative";
- break;
- default:
- }
+ const symbolClassMap = {BAYES_SPAM: "symbol-positive", BAYES_HAM: "symbol-negative"};
+ const cls = symbolClassMap[statfile.symbol] || "";
$("#bayesTable tbody").append("<tr>" +
(i === 0 ? '<td rowspan="' + statfiles.length + '">' + server + "</td>" : "") +
'<td class="' + cls + '">' + statfile.symbol + "</td>" +