WebUI: replace deprecated data type

`Hash` is deprecated by mootools.
Also simplify related code.

PR #22458.
This commit is contained in:
Chocobo1 2025-03-23 15:01:39 +08:00 committed by GitHub
commit 7b4a3fccc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1866,22 +1866,32 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
}; };
const getWatchedFolders = () => { const getWatchedFolders = () => {
const nb_folders = $("watched_folders_tab").getChildren("tbody")[0].getChildren("tr").length; const folders = {};
const folders = new Hash();
for (let i = 0; i < nb_folders; ++i) { const entryCount = $("watched_folders_tab").getChildren("tbody")[0].getChildren("tr").length;
for (let i = 0; i < entryCount; ++i) {
const fpath = $(`text_watch_${i}`).value.trim(); const fpath = $(`text_watch_${i}`).value.trim();
if (fpath.length > 0) { if (fpath.length <= 0)
const sel = $(`cb_watch_${i}`).value.trim(); continue;
let other; const sel = $(`cb_watch_${i}`).value.trim();
if (sel === "other")
let other;
switch (sel) {
case "watch_folder":
other = 0;
break;
case "default_folder":
other = 1;
break;
case "other":
other = $(`cb_watch_txt_${i}`).value.trim(); other = $(`cb_watch_txt_${i}`).value.trim();
else break;
other = (sel === "watch_folder") ? 0 : 1; };
folders.set(fpath, other); folders[fpath] = other;
}
} }
return folders; return folders;
}; };
@ -2297,14 +2307,11 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
continue; continue;
const folderType = pref.scan_dirs[folder]; const folderType = pref.scan_dirs[folder];
let sel = ""; let sel = "other";
let other = ""; let other = folderType;
if (typeof folderType === "number") { if (typeof folderType === "number") {
sel = (folderType === 0) ? "watch_folder" : "default_folder"; sel = (folderType === 0) ? "watch_folder" : "default_folder";
} other = "";
else {
sel = "other";
other = folderType;
} }
addWatchFolder(folder, sel, other); addWatchFolder(folder, sel, other);
} }