2 <html lang=
"${LANG}" class=
"dark">
6 <title>QBT_TR(Renaming)QBT_TR[CONTEXT=TorrentContentTreeView]
</title>
7 <link rel=
"stylesheet" href=
"css/style.css?v=${CACHEID}" type=
"text/css">
8 <script src=
"scripts/lib/MooTools-Core-1.6.0-compat-compressed.js"></script>
9 <script src=
"scripts/lib/MooTools-More-1.6.0-compat-compressed.js"></script>
10 <script src=
"scripts/localpreferences.js?v=${CACHEID}"></script>
11 <script src=
"scripts/color-scheme.js?v=${CACHEID}"></script>
12 <script src=
"scripts/misc.js?locale=${LANG}&v=${CACHEID}"></script>
13 <script src=
"scripts/filesystem.js?v=${CACHEID}"></script>
17 window
.addEventListener("DOMContentLoaded", () => {
18 window
.addEventListener("keydown", (event
) => {
21 event
.preventDefault();
22 $("renameButton").click();
25 event
.preventDefault();
26 window
.parent
.qBittorrent
.Client
.closeFrameWindow(window
);
31 const searchParams
= new URLSearchParams(window
.location
.search
);
32 const hash
= searchParams
.get("hash");
33 const oldPath
= searchParams
.get("path");
34 const isFolder
= ((searchParams
.get("isFolder")) === "true");
36 const oldName
= window
.qBittorrent
.Filesystem
.fileName(oldPath
);
37 $("rename").value
= oldName
;
40 $("rename").setSelectionRange(0, oldName
.lastIndexOf("."));
42 $("renameButton").addEventListener("click", (e
) => {
47 const newName
= $("rename").value
.trim();
49 alert("QBT_TR(Name cannot be empty)QBT_TR[CONTEXT=HttpServer]");
53 if (newName
=== oldName
) {
54 alert("QBT_TR(Name is unchanged)QBT_TR[CONTEXT=HttpServer]");
58 $("renameButton").disabled
= true;
60 const parentPath
= window
.qBittorrent
.Filesystem
.folderName(oldPath
);
61 const newPath
= parentPath
62 ? parentPath
+ window
.qBittorrent
.Filesystem
.PathSeparator
+ newName
64 fetch((isFolder
? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile"), {
66 body
: new URLSearchParams({
74 alert("QBT_TR(Failed to update name)QBT_TR[CONTEXT=HttpServer]");
75 $("renameButton").disabled
= false;
79 window
.parent
.qBittorrent
.Client
.closeFrameWindow(window
);
87 <div style=
"padding: 10px 10px 0px 10px;">
88 <label for=
"rename" style=
"font-weight: bold;">QBT_TR(New name:)QBT_TR[CONTEXT=TorrentContentTreeView]
</label>
89 <input type=
"text" id=
"rename" style=
"width: 99%;">
90 <div style=
"text-align: center; padding-top: 10px;">
91 <input type=
"button" value=
"QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" id=
"renameButton">