From 2f2e1588773ab5c7673e974d833dfe28bb6a4ae1 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 9 Jun 2024 18:43:47 +0800 Subject: [PATCH] WebUI: unify comment format --- src/webui/www/eslint.config.mjs | 3 +- src/webui/www/private/scripts/client.js | 2 +- src/webui/www/private/scripts/contextmenu.js | 42 +++++++++---------- src/webui/www/private/scripts/dynamicTable.js | 2 +- .../www/private/scripts/prop-webseeds.js | 2 +- src/webui/www/private/views/rss.html | 4 +- src/webui/www/private/views/transferlist.html | 2 +- 7 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/webui/www/eslint.config.mjs b/src/webui/www/eslint.config.mjs index 520c4e3e6..e77e7d422 100644 --- a/src/webui/www/eslint.config.mjs +++ b/src/webui/www/eslint.config.mjs @@ -53,7 +53,8 @@ export default [ "allowTemplateLiterals": true } ], - "Stylistic/semi": "error" + "Stylistic/semi": "error", + "Stylistic/spaced-comment": ["error", "always", { "exceptions": ["*"] }] } } ]; diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 57bffeb47..a26e5c254 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -172,7 +172,7 @@ window.addEventListener("DOMContentLoaded", () => { saveColumnSizes.delay(200); // Resizing might takes some time. }); - /*MochaUI.Desktop = new MochaUI.Desktop(); + /* MochaUI.Desktop = new MochaUI.Desktop(); MochaUI.Desktop.desktop.setStyles({ 'background': '#fff', 'visibility': 'visible' diff --git a/src/webui/www/private/scripts/contextmenu.js b/src/webui/www/private/scripts/contextmenu.js index 8d37c6cc2..388555ffd 100644 --- a/src/webui/www/private/scripts/contextmenu.js +++ b/src/webui/www/private/scripts/contextmenu.js @@ -47,10 +47,10 @@ window.qBittorrent.ContextMenu = (function() { let lastShownContextMenu = null; const ContextMenu = new Class({ - //implements + // implements Implements: [Options, Events], - //options + // options options: { actions: {}, menu: "menu_id", @@ -67,16 +67,16 @@ window.qBittorrent.ContextMenu = (function() { touchTimer: 600 }, - //initialization + // initialization initialize: function(options) { - //set options + // set options this.setOptions(options); - //option diffs menu + // option diffs menu this.menu = $(this.options.menu); this.targets = $$(this.options.targets); - //fx + // fx this.fx = new Fx.Tween(this.menu, { property: "opacity", duration: this.options.fadeSpeed, @@ -88,10 +88,10 @@ window.qBittorrent.ContextMenu = (function() { }.bind(this.menu) }); - //hide and begin the listener + // hide and begin the listener this.hide().startListener(); - //hide the menu + // hide the menu this.menu.setStyles({ "position": "absolute", "top": "-900000px", @@ -197,17 +197,17 @@ window.qBittorrent.ContextMenu = (function() { if (this.options.disabled) return; - //prevent default, if told to + // prevent default, if told to if (this.options.stopEvent) e.stop(); - //record this as the trigger + // record this as the trigger this.options.element = $(el); this.adjustMenuPosition(e); - //show the menu + // show the menu this.show(); }, - //get things started + // get things started startListener: function() { /* all elements */ this.targets.each((el) => { @@ -225,7 +225,7 @@ window.qBittorrent.ContextMenu = (function() { }); }, this); - //hide on body click + // hide on body click $(document.body).addEvent("click", () => { this.hide(); }); @@ -233,7 +233,7 @@ window.qBittorrent.ContextMenu = (function() { updateMenuItems: function() {}, - //show menu + // show menu show: function(trigger) { if (lastShownContextMenu && (lastShownContextMenu !== this)) lastShownContextMenu.hide(); @@ -243,11 +243,11 @@ window.qBittorrent.ContextMenu = (function() { return this; }, - //hide the menu + // hide the menu hide: function(trigger) { if (lastShownContextMenu && (lastShownContextMenu.menu.style.visibility !== "hidden")) { this.fx.start(0); - //this.menu.fade('out'); + // this.menu.fade('out'); this.fireEvent("hide"); } return this; @@ -263,31 +263,31 @@ window.qBittorrent.ContextMenu = (function() { return this.menu.getElement("a[href$=" + item + "]").firstChild.style.opacity !== "0"; }, - //hide an item + // hide an item hideItem: function(item) { this.menu.getElement("a[href$=" + item + "]").parentNode.addClass("invisible"); return this; }, - //show an item + // show an item showItem: function(item) { this.menu.getElement("a[href$=" + item + "]").parentNode.removeClass("invisible"); return this; }, - //disable the entire menu + // disable the entire menu disable: function() { this.options.disabled = true; return this; }, - //enable the entire menu + // enable the entire menu enable: function() { this.options.disabled = false; return this; }, - //execute an action + // execute an action execute: function(action, element) { if (this.options.actions[action]) this.options.actions[action](element, this, action); diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index 58318f206..1fa668920 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -3126,7 +3126,7 @@ window.qBittorrent.DynamicTable = (function() { }; this.columns["type"].updateTd = function(td, row) { - //Type of the message: Log::NORMAL: 1, Log::INFO: 2, Log::WARNING: 4, Log::CRITICAL: 8 + // Type of the message: Log::NORMAL: 1, Log::INFO: 2, Log::WARNING: 4, Log::CRITICAL: 8 let logLevel, addClass; switch (this.getRowValue(row).toInt()) { case 1: diff --git a/src/webui/www/private/scripts/prop-webseeds.js b/src/webui/www/private/scripts/prop-webseeds.js index e2e4ab31e..dc15ba776 100644 --- a/src/webui/www/private/scripts/prop-webseeds.js +++ b/src/webui/www/private/scripts/prop-webseeds.js @@ -76,7 +76,7 @@ window.qBittorrent.PropWebseeds = (function() { this.updateRow(tableRow, row); return; } - //this.removeRow(id); + // this.removeRow(id); const tr = new Element("tr"); this.rows.set(url, tr); for (let i = 0; i < row.length; ++i) { diff --git a/src/webui/www/private/views/rss.html b/src/webui/www/private/views/rss.html index 3e6e2f518..3573bf91e 100644 --- a/src/webui/www/private/views/rss.html +++ b/src/webui/www/private/views/rss.html @@ -376,7 +376,7 @@ })); } } - //filter read articles if "Unread" feed is selected + // filter read articles if "Unread" feed is selected if (path === "") visibleArticles = visibleArticles.filter((a) => !a.isRead); @@ -427,7 +427,7 @@ $("rssDetailsView").append(torrentDescription); document.getElementById("rssDescription").srcdoc = '' + article.description + ""; - //calculate height to fill screen + // calculate height to fill screen document.getElementById("rssDescription").style.height = "calc(100% - " + document.getElementById("rssTorrentDetailsName").offsetHeight + "px - " + document.getElementById("rssTorrentDetailsDate").offsetHeight + "px - 5px)"; diff --git a/src/webui/www/private/views/transferlist.html b/src/webui/www/private/views/transferlist.html index a94716585..1cb180b25 100644 --- a/src/webui/www/private/views/transferlist.html +++ b/src/webui/www/private/views/transferlist.html @@ -28,7 +28,7 @@ }; }; - //create a context menu + // create a context menu const contextMenu = new window.qBittorrent.ContextMenu.TorrentsTableContextMenu({ targets: ".torrentsTableContextMenuTarget", menu: "torrentsTableMenu",