WebUI: avoid redundant re-initialization

PR #21012.
This commit is contained in:
Chocobo1 2024-07-12 15:00:36 +08:00 committed by GitHub
commit 9feefc8144
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 174 additions and 240 deletions

View file

@ -28,10 +28,8 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.Cache = (() => {
window.qBittorrent ??= {};
window.qBittorrent.Cache ??= (() => {
const exports = () => {
return {
buildInfo: new BuildInfoCache(),
@ -170,5 +168,4 @@ window.qBittorrent.Cache = (() => {
return exports();
})();
Object.freeze(window.qBittorrent.Cache);

View file

@ -25,10 +25,8 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.Client = (() => {
window.qBittorrent ??= {};
window.qBittorrent.Client ??= (() => {
const exports = () => {
return {
closeWindows: closeWindows,

View file

@ -28,11 +28,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.ContextMenu = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.ContextMenu ??= (() => {
const exports = () => {
return {
ContextMenu: ContextMenu,
TorrentsTableContextMenu: TorrentsTableContextMenu,
@ -680,5 +678,4 @@ window.qBittorrent.ContextMenu = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.ContextMenu);

View file

@ -23,11 +23,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.Download = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.Download ??= (() => {
const exports = () => {
return {
changeCategorySelect: changeCategorySelect,
changeTMM: changeTMM
@ -138,5 +136,4 @@ window.qBittorrent.Download = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.Download);

View file

@ -33,11 +33,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.DynamicTable = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.DynamicTable ??= (() => {
const exports = () => {
return {
TorrentsTable: TorrentsTable,
TorrentPeersTable: TorrentPeersTable,
@ -3279,7 +3277,6 @@ window.qBittorrent.DynamicTable = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.DynamicTable);
/*************************************************************/

View file

@ -28,11 +28,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.FileTree = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.FileTree ??= (() => {
const exports = () => {
return {
FilePriority: FilePriority,
TriState: TriState,
@ -196,5 +194,4 @@ window.qBittorrent.FileTree = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.FileTree);

View file

@ -30,11 +30,9 @@
// This file is the JavaScript implementation of base/utils/fs.cpp
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.Filesystem = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.Filesystem ??= (() => {
const exports = () => {
return {
PathSeparator: PathSeparator,
fileExtension: fileExtension,
@ -71,5 +69,4 @@ window.qBittorrent.Filesystem = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.Filesystem);

View file

@ -28,11 +28,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.LocalPreferences = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.LocalPreferences ??= (() => {
const exports = () => {
return {
LocalPreferencesClass: LocalPreferencesClass
};
@ -67,5 +65,4 @@ window.qBittorrent.LocalPreferences = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.LocalPreferences);

View file

@ -28,11 +28,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.Misc = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.Misc ??= (() => {
const exports = () => {
return {
friendlyUnit: friendlyUnit,
friendlyDuration: friendlyDuration,
@ -230,5 +228,4 @@ window.qBittorrent.Misc = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.Misc);

View file

@ -31,11 +31,9 @@
/*
File implementing auto-fill for the path input field in the path dialogs.
*/
if (window.qBittorrent === undefined)
window.qBittorrent = {};
if (window.qBittorrent.pathAutofill === undefined) {
window.qBittorrent.pathAutofill = (() => {
window.qBittorrent ??= {};
window.qBittorrent.pathAutofill ??= (() => {
const exports = () => {
return {
attachPathAutofill: attachPathAutofill
@ -88,6 +86,4 @@ if (window.qBittorrent.pathAutofill === undefined) {
return exports();
})();
Object.freeze(window.qBittorrent.pathAutofill);
};

View file

@ -28,10 +28,8 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.PiecesBar = (() => {
window.qBittorrent ??= {};
window.qBittorrent.PiecesBar ??= (() => {
const exports = () => {
return {
PiecesBar: PiecesBar
@ -267,5 +265,4 @@ window.qBittorrent.PiecesBar = (() => {
return exports();
})();
Object.freeze(window.qBittorrent.PiecesBar);

View file

@ -28,11 +28,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.ProgressBar = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.ProgressBar ??= (() => {
const exports = () => {
return {
ProgressBar: ProgressBar
};
@ -157,5 +155,4 @@ window.qBittorrent.ProgressBar = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.ProgressBar);

View file

@ -28,11 +28,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.PropFiles = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.PropFiles ??= (() => {
const exports = () => {
return {
normalizePriority: normalizePriority,
isDownloadCheckboxExists: isDownloadCheckboxExists,
@ -769,5 +767,4 @@ window.qBittorrent.PropFiles = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.PropFiles);

View file

@ -28,11 +28,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.PropGeneral = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.PropGeneral ??= (() => {
const exports = () => {
return {
updateData: updateData
};
@ -257,5 +255,4 @@ window.qBittorrent.PropGeneral = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.PropGeneral);

View file

@ -28,11 +28,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.PropPeers = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.PropPeers ??= (() => {
const exports = () => {
return {
updateData: updateData
};
@ -182,5 +180,4 @@ window.qBittorrent.PropPeers = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.PropPeers);

View file

@ -28,11 +28,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.PropTrackers = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.PropTrackers ??= (() => {
const exports = () => {
return {
updateData: updateData
};
@ -237,5 +235,4 @@ window.qBittorrent.PropTrackers = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.PropTrackers);

View file

@ -28,11 +28,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.PropWebseeds = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.PropWebseeds ??= (() => {
const exports = () => {
return {
updateData: updateData
};
@ -148,5 +146,4 @@ window.qBittorrent.PropWebseeds = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.PropWebseeds);

View file

@ -1,10 +1,8 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.MultiRename = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.MultiRename ??= (() => {
const exports = () => {
return {
AppliesTo: AppliesTo,
RenameFiles: RenameFiles
@ -282,5 +280,4 @@ window.qBittorrent.MultiRename = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.MultiRename);

View file

@ -23,11 +23,9 @@
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.Search = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.Search ??= (() => {
const exports = () => {
return {
startStopSearch: startStopSearch,
manageSearchPlugins: manageSearchPlugins,
@ -866,5 +864,4 @@ window.qBittorrent.Search = (function() {
return exports();
})();
Object.freeze(window.qBittorrent.Search);

View file

@ -44,11 +44,9 @@
<script>
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.Filters = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.Filters ??= (() => {
const exports = () => {
return {
categoriesFilterContextMenu: categoriesFilterContextMenu,
tagsFilterContextMenu: tagsFilterContextMenu,
@ -163,6 +161,5 @@
return exports();
})();
Object.freeze(window.qBittorrent.Filters);
</script>

View file

@ -29,17 +29,16 @@
<script>
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.InstallSearchPlugin = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.InstallSearchPlugin ??= (() => {
const exports = () => {
return {
setup: setup,
newPluginOk: newPluginOk
};
};
const init = function() {
const setup = function() {
new Keyboard({
defaultEventType: "keydown",
events: {
@ -75,10 +74,9 @@
}
};
init();
return exports();
})();
Object.freeze(window.qBittorrent.InstallSearchPlugin);
window.qBittorrent.InstallSearchPlugin.setup();
</script>

View file

@ -148,10 +148,8 @@
<script>
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.Log = (() => {
window.qBittorrent ??= {};
window.qBittorrent.Log ??= (() => {
const exports = () => {
return {
init: init,
@ -430,6 +428,5 @@
return exports();
})();
Object.freeze(window.qBittorrent.Log);
</script>

View file

@ -1572,12 +1572,11 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
<script>
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.Preferences = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.Preferences ??= (() => {
const exports = () => {
return {
setup: setup,
numberInputLimiter: numberInputLimiter,
updateFileLogEnabled: updateFileLogEnabled,
updateFileLogBackupEnabled: updateFileLogBackupEnabled,
@ -1654,7 +1653,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
};
// Downloads tab
const watchedFoldersTable = new HtmlTable($("watched_folders_tab"));
let watchedFoldersTable;
const updateTempDirEnabled = function() {
const isTempDirEnabled = $("temppath_checkbox").checked;
@ -2886,9 +2885,12 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
});
};
// hide entries
const setup = () => {
watchedFoldersTable = new HtmlTable($("watched_folders_tab"));
const buildInfo = window.qBittorrent.Cache.buildInfo.get();
// hide entries
const libtorrentVersion = window.qBittorrent.Misc.parseVersion(buildInfo.libtorrent);
if (libtorrentVersion.valid) {
if (libtorrentVersion.major >= 2) {
@ -2920,10 +2922,12 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
loadPreferences();
window.qBittorrent.pathAutofill.attachPathAutofill();
};
return exports();
})();
Object.freeze(window.qBittorrent.Preferences);
window.qBittorrent.pathAutofill.attachPathAutofill();
window.qBittorrent.Preferences.setup();
</script>

View file

@ -158,12 +158,8 @@
<script>
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
const serverSyncRssDataInterval = 1500;
window.qBittorrent.Rss = (() => {
window.qBittorrent ??= {};
window.qBittorrent.Rss ??= (() => {
const exports = () => {
return {
init: init,
@ -181,6 +177,7 @@
};
};
const serverSyncRssDataInterval = 1500;
let feedData = {};
let pathByFeedId = new Map();
let feedRefreshTimer;
@ -828,6 +825,5 @@
return exports();
})();
Object.freeze(window.qBittorrent.Rss);
</script>

View file

@ -330,12 +330,11 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
<script>
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.RssDownloader = (() => {
window.qBittorrent ??= {};
window.qBittorrent.RssDownloader ??= (() => {
const exports = () => {
return {
setup: setup,
updateRulesList: updateRulesList,
showRule: showRule,
renameRule: renameRule,
@ -356,7 +355,7 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
let rulesList = {};
let feedList = [];
const initRssDownloader = () => {
const setup = () => {
const pref = window.parent.qBittorrent.Cache.preferences.get();
if (!pref.rss_auto_downloading_enabled)
@ -808,9 +807,9 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
$("episodeFilterText").title = episodeFilterTitle;
};
initRssDownloader();
return exports();
})();
Object.freeze(window.qBittorrent.RssDownloader);
window.qBittorrent.RssDownloader.setup();
</script>

View file

@ -79,13 +79,12 @@
<script>
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.SearchPlugins = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.SearchPlugins ??= (() => {
const exports = () => {
return {
closeSearchWindow: closeSearchWindow,
setup: setup,
installPlugin: installPlugin,
checkForUpdates: checkForUpdates,
updateTable: updateTable
@ -97,7 +96,7 @@
let prevOffsetLeft;
let prevOffsetTop;
const initSearchPlugins = function() {
const setup = function() {
searchPluginsTable = new window.qBittorrent.DynamicTable.SearchPluginsTable();
searchPluginsTableContextMenu = new window.qBittorrent.ContextMenu.SearchPluginsTableContextMenu({
targets: ".searchPluginsTableRow",
@ -230,10 +229,9 @@
setupSearchPluginTableEvents(true);
};
initSearchPlugins();
return exports();
})();
Object.freeze(window.qBittorrent.SearchPlugins);
window.qBittorrent.SearchPlugins.setup();
</script>

View file

@ -18,12 +18,11 @@
<script>
"use strict";
if (window.qBittorrent === undefined)
window.qBittorrent = {};
window.qBittorrent.TransferList = (function() {
const exports = function() {
window.qBittorrent ??= {};
window.qBittorrent.TransferList ??= (() => {
const exports = () => {
return {
setup: setup,
contextMenu: contextMenu,
};
};
@ -111,10 +110,13 @@
},
});
const setup = () => {
torrentsTable.setup("torrentsTableDiv", "torrentsTableFixedHeaderDiv", contextMenu);
};
return exports();
})();
Object.freeze(window.qBittorrent.TransferList);
window.qBittorrent.TransferList.setup();
</script>