Skip to content

Commit

Permalink
WebUI: use template literals instead of string concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobo1 committed Jan 14, 2025
1 parent 8db360e commit e400767
Show file tree
Hide file tree
Showing 18 changed files with 126 additions and 126 deletions.
1 change: 1 addition & 0 deletions src/webui/www/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default [
"operator-assignment": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-template": "error",
"radix": "error",
"PreferArrowFunctions/prefer-arrow-functions": "error",
"Stylistic/no-mixed-operators": [
Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/private/newcategory.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
})
.then((response) => {
if (!response.ok) {
alert("QBT_TR(Unable to create category)QBT_TR[CONTEXT=Category] " + window.qBittorrent.Misc.escapeHtml(categoryName));
alert(`QBT_TR(Unable to create category)QBT_TR[CONTEXT=Category] ${window.qBittorrent.Misc.escapeHtml(categoryName)}`);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/private/rename_files.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
// Update renamed column for matched rows
for (let i = 0; i < matchedRows.length; ++i) {
const row = matchedRows[i];
$("filesTablefileRenamed" + row.rowId).textContent = row.renamed;
$(`filesTablefileRenamed${row.rowId}`).textContent = row.renamed;
}
};
fileRenamer.onInvalidRegex = (err) => {
Expand Down
26 changes: 13 additions & 13 deletions src/webui/www/private/scripts/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ window.qBittorrent.Client ??= (() => {
const mainTitle = () => {
const emDash = "\u2014";
const qbtVersion = window.qBittorrent.Cache.qbtVersion.get();
const suffix = window.qBittorrent.Cache.preferences.get()["app_instance_name"] || "";
const title = `qBittorrent ${qbtVersion} QBT_TR(WebUI)QBT_TR[CONTEXT=OptionsDialog]`
+ ((suffix.length > 0) ? ` ${emDash} ${suffix}` : "");
let suffix = window.qBittorrent.Cache.preferences.get()["app_instance_name"] || "";
if (suffix.length > 0)
suffix = ` ${emDash} ${suffix}`;
const title = `qBittorrent ${qbtVersion} QBT_TR(WebUI)QBT_TR[CONTEXT=OptionsDialog]${suffix}`;
return title;
};

Expand Down Expand Up @@ -952,13 +953,13 @@ window.addEventListener("DOMContentLoaded", () => {
const processServerState = () => {
let transfer_info = window.qBittorrent.Misc.friendlyUnit(serverState.dl_info_speed, true);
if (serverState.dl_rate_limit > 0)
transfer_info += " [" + window.qBittorrent.Misc.friendlyUnit(serverState.dl_rate_limit, true) + "]";
transfer_info += " (" + window.qBittorrent.Misc.friendlyUnit(serverState.dl_info_data, false) + ")";
transfer_info += ` [${window.qBittorrent.Misc.friendlyUnit(serverState.dl_rate_limit, true)}]`;
transfer_info += ` (${window.qBittorrent.Misc.friendlyUnit(serverState.dl_info_data, false)})`;
$("DlInfos").textContent = transfer_info;
transfer_info = window.qBittorrent.Misc.friendlyUnit(serverState.up_info_speed, true);
if (serverState.up_rate_limit > 0)
transfer_info += " [" + window.qBittorrent.Misc.friendlyUnit(serverState.up_rate_limit, true) + "]";
transfer_info += " (" + window.qBittorrent.Misc.friendlyUnit(serverState.up_info_data, false) + ")";
transfer_info += ` [${window.qBittorrent.Misc.friendlyUnit(serverState.up_rate_limit, true)}]`;
transfer_info += ` (${window.qBittorrent.Misc.friendlyUnit(serverState.up_info_data, false)})`;
$("UpInfos").textContent = transfer_info;

document.title = (speedInTitle
Expand Down Expand Up @@ -1010,12 +1011,12 @@ window.addEventListener("DOMContentLoaded", () => {
$("TotalWastedSession").textContent = window.qBittorrent.Misc.friendlyUnit(serverState.total_wasted_session, false);
$("GlobalRatio").textContent = serverState.global_ratio;
$("TotalPeerConnections").textContent = serverState.total_peer_connections;
$("ReadCacheHits").textContent = serverState.read_cache_hits + "%";
$("ReadCacheHits").textContent = `${serverState.read_cache_hits}%`;
$("TotalBuffersSize").textContent = window.qBittorrent.Misc.friendlyUnit(serverState.total_buffers_size, false);
$("WriteCacheOverload").textContent = serverState.write_cache_overload + "%";
$("ReadCacheOverload").textContent = serverState.read_cache_overload + "%";
$("WriteCacheOverload").textContent = `${serverState.write_cache_overload}%`;
$("ReadCacheOverload").textContent = `${serverState.read_cache_overload}%`;
$("QueuedIOJobs").textContent = serverState.queued_io_jobs;
$("AverageTimeInQueue").textContent = serverState.average_time_queue + " ms";
$("AverageTimeInQueue").textContent = `${serverState.average_time_queue} ms`;
$("TotalQueuedSize").textContent = window.qBittorrent.Misc.friendlyUnit(serverState.total_queued_size, false);
}

Expand Down Expand Up @@ -1149,8 +1150,7 @@ window.addEventListener("DOMContentLoaded", () => {
hashParams.set("download", "");

const templateHashString = hashParams.toString().replace("download=", "download=%s");
const templateUrl = location.origin + location.pathname
+ location.search + "#" + templateHashString;
const templateUrl = `${location.origin}${location.pathname}${location.search}#${templateHashString}`;

navigator.registerProtocolHandler("magnet", templateUrl,
"qBittorrent WebUI magnet handler");
Expand Down
Loading

0 comments on commit e400767

Please sign in to comment.