GHA CI: add checking for GHA workflows
[qBittorrent.git] / src / webui / www / private / rename_file.html
blob8cddc935b08507a32c4dab49bbddf1f021fa82a5
1 <!DOCTYPE html>
2 <html lang="${LANG}" class="dark">
4 <head>
5 <meta charset="UTF-8">
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>
14 <script>
15 "use strict";
17 window.addEventListener("DOMContentLoaded", () => {
18 window.addEventListener("keydown", (event) => {
19 switch (event.key) {
20 case "Enter":
21 event.preventDefault();
22 $("renameButton").click();
23 break;
24 case "Escape":
25 event.preventDefault();
26 window.parent.qBittorrent.Client.closeFrameWindow(window);
27 break;
29 });
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;
38 $("rename").focus();
39 if (!isFolder)
40 $("rename").setSelectionRange(0, oldName.lastIndexOf("."));
42 $("renameButton").addEventListener("click", (e) => {
43 e.preventDefault();
44 e.stopPropagation();
46 // check field
47 const newName = $("rename").value.trim();
48 if (newName === "") {
49 alert("QBT_TR(Name cannot be empty)QBT_TR[CONTEXT=HttpServer]");
50 return;
53 if (newName === oldName) {
54 alert("QBT_TR(Name is unchanged)QBT_TR[CONTEXT=HttpServer]");
55 return;
58 $("renameButton").disabled = true;
60 const parentPath = window.qBittorrent.Filesystem.folderName(oldPath);
61 const newPath = parentPath
62 ? parentPath + window.qBittorrent.Filesystem.PathSeparator + newName
63 : newName;
64 fetch((isFolder ? "api/v2/torrents/renameFolder" : "api/v2/torrents/renameFile"), {
65 method: "POST",
66 body: new URLSearchParams({
67 hash: hash,
68 oldPath: oldPath,
69 newPath: newPath
72 .then((response) => {
73 if (!response.ok) {
74 alert("QBT_TR(Failed to update name)QBT_TR[CONTEXT=HttpServer]");
75 $("renameButton").disabled = false;
76 return;
79 window.parent.qBittorrent.Client.closeFrameWindow(window);
80 });
81 });
82 });
83 </script>
84 </head>
86 <body>
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">
92 </div>
93 </div>
94 </body>
96 </html>