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 hash
= new URI().getData("hash");
32 const oldPath
= new URI().getData("path");
33 const isFolder
= ((new URI().getData("isFolder")) === "true");
35 const oldName
= window
.qBittorrent
.Filesystem
.fileName(oldPath
);
36 $("rename").value
= oldName
;
39 $("rename").setSelectionRange(0, oldName
.lastIndexOf("."));
41 $("renameButton").addEventListener("click", (e
) => {
46 const newName
= $("rename").value
.trim();
48 alert("QBT_TR(Name cannot be empty)QBT_TR[CONTEXT=HttpServer]");
52 if (newName
=== oldName
) {
53 alert("QBT_TR(Name is unchanged)QBT_TR[CONTEXT=HttpServer]");
57 $("renameButton").disabled
= true;
59 const parentPath
= window
.qBittorrent
.Filesystem
.folderName(oldPath
);
60 const newPath
= parentPath
61 ? parentPath
+ window
.qBittorrent
.Filesystem
.PathSeparator
+ newName
63 fetch((isFolder
? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile"), {
65 body
: new URLSearchParams({
73 alert("QBT_TR(Failed to update name)QBT_TR[CONTEXT=HttpServer]");
74 $("renameButton").disabled
= false;
78 window
.parent
.qBittorrent
.Client
.closeFrameWindow(window
);
86 <div style=
"padding: 10px 10px 0px 10px;">
87 <label for=
"rename" style=
"font-weight: bold;">QBT_TR(New name:)QBT_TR[CONTEXT=TorrentContentTreeView]
</label>
88 <input type=
"text" id=
"rename" style=
"width: 99%;">
89 <div style=
"text-align: center; padding-top: 10px;">
90 <input type=
"button" value=
"QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" id=
"renameButton">