WebUI: inline redundant function
[qBittorrent.git] / src / webui / www / private / rename_feed.html
blobd11f41935e923397b39523d309a6ab56b6a7f707
1 <!DOCTYPE html>
2 <html lang="${LANG}" class="dark">
4 <head>
5 <meta charset="UTF-8">
6 <title>QBT_TR(Please choose a new name for this RSS feed)QBT_TR[CONTEXT=RSSWidget]</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>
14 "use strict";
16 window.addEventListener("DOMContentLoaded", () => {
17 window.addEventListener("keydown", (event) => {
18 switch (event.key) {
19 case "Enter":
20 event.preventDefault();
21 $("renameButton").click();
22 break;
23 case "Escape":
24 event.preventDefault();
25 window.parent.qBittorrent.Client.closeFrameWindow(window);
26 break;
28 });
30 const oldPath = new URLSearchParams(window.location.search).get("oldPath");
32 $("rename").value = oldPath;
33 $("rename").focus();
34 $("rename").setSelectionRange(0, oldPath.length);
36 $("renameButton").addEventListener("click", (e) => {
37 e.preventDefault();
38 e.stopPropagation();
40 // check field
41 const newPath = $("rename").value.trim();
42 if (newPath === "") {
43 alert("QBT_TR(Name cannot be empty)QBT_TR[CONTEXT=HttpServer]");
44 return;
47 if (newPath === oldPath) {
48 alert("QBT_TR(Name is unchanged)QBT_TR[CONTEXT=HttpServer]");
49 return;
52 $("renameButton").disabled = true;
54 fetch("api/v2/rss/moveItem", {
55 method: "POST",
56 body: new URLSearchParams({
57 itemPath: oldPath,
58 destPath: newPath
61 .then(async (response) => {
62 if (!response.ok) {
63 if (response.status === 409)
64 alert(await response.text());
65 $("renameButton").disabled = false;
66 return;
69 window.parent.qBittorrent.Rss.updateRssFeedList();
70 window.parent.qBittorrent.Client.closeFrameWindow(window);
71 });
72 });
73 });
74 </script>
75 </head>
77 <body>
78 <div style="padding: 10px 10px 0px 10px;">
79 <label for="rename" style="font-weight: bold;">QBT_TR(New feed name:)QBT_TR[CONTEXT=RSSWidget]</label>
80 <input type="text" id="rename" style="width: 320px;">
81 <div style="text-align: center; padding-top: 10px;">
82 <input type="button" value="QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" id="renameButton">
83 </div>
84 </div>
85 </body>
87 </html>