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/misc.js?locale=${LANG}&v=${CACHEID}"></script>
11 <script src=
"scripts/filesystem.js?v=${CACHEID}"></script>
16 defaultEventType
: "keydown",
18 "Enter": function(event
) {
19 $("renameButton").click();
20 event
.preventDefault();
22 "Escape": function(event
) {
23 window
.parent
.qBittorrent
.Client
.closeWindows();
24 event
.preventDefault();
26 "Esc": function(event
) {
27 window
.parent
.qBittorrent
.Client
.closeWindows();
28 event
.preventDefault();
33 window
.addEventListener("DOMContentLoaded", () => {
34 const hash
= new URI().getData("hash");
35 const oldPath
= new URI().getData("path");
36 const isFolder
= ((new URI().getData("isFolder")) === "true");
38 const oldName
= window
.qBittorrent
.Filesystem
.fileName(oldPath
);
39 $("rename").value
= oldName
;
42 $("rename").setSelectionRange(0, oldName
.lastIndexOf("."));
44 $("renameButton").addEventListener("click", (e
) => {
49 const newName
= $("rename").value
.trim();
51 alert("QBT_TR(Name cannot be empty)QBT_TR[CONTEXT=HttpServer]");
55 if (newName
=== oldName
) {
56 alert("QBT_TR(Name is unchanged)QBT_TR[CONTEXT=HttpServer]");
60 $("renameButton").disabled
= true;
62 const parentPath
= window
.qBittorrent
.Filesystem
.folderName(oldPath
);
63 const newPath
= parentPath
64 ? parentPath
+ window
.qBittorrent
.Filesystem
.PathSeparator
+ newName
67 url
: isFolder
? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile",
74 onSuccess: function() {
75 window
.parent
.qBittorrent
.Client
.closeWindows();
77 onFailure: function() {
78 alert("QBT_TR(Failed to update name)QBT_TR[CONTEXT=HttpServer]");
79 $("renameButton").disabled
= false;
88 <div style=
"padding: 10px 10px 0px 10px;">
89 <label for=
"rename" style=
"font-weight: bold;">QBT_TR(New name:)QBT_TR[CONTEXT=TorrentContentTreeView]
</label>
90 <input type=
"text" id=
"rename" style=
"width: 99%;">
91 <div style=
"text-align: center; padding-top: 10px;">
92 <input type=
"button" value=
"QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" id=
"renameButton">