WebUI: Remove redundant event listener
[qBittorrent.git] / src / webui / www / private / editfeedurl.html
blob83ffbd9d0e312bb699546c6b1f5e75cbbcdc9f0d
1 <!DOCTYPE html>
2 <html lang="${LANG}" class="dark">
4 <head>
5 <meta charset="UTF-8">
6 <title>QBT_TR(Please type a RSS feed URL)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 $("submitButton").click();
22 break;
23 case "Escape":
24 event.preventDefault();
25 window.parent.qBittorrent.Client.closeFrameWindow(window);
26 break;
28 });
30 const currentUrl = new URI().getData("url");
32 $("url").value = currentUrl;
33 $("url").focus();
34 $("url").setSelectionRange(0, currentUrl.length);
36 $("submitButton").addEventListener("click", (e) => {
37 e.preventDefault();
38 e.stopPropagation();
40 // check field
41 const newUrl = $("url").value.trim();
42 if (newUrl === "") {
43 alert("QBT_TR(URL cannot be empty)QBT_TR[CONTEXT=RSSWidget]");
44 return;
47 if (newUrl === currentUrl) {
48 alert("QBT_TR(URL is unchanged)QBT_TR[CONTEXT=RSSWidget]");
49 return;
52 $("submitButton").disabled = true;
54 fetch("api/v2/rss/setFeedURL", {
55 method: "POST",
56 body: new URLSearchParams({
57 path: new URI().getData("path"),
58 url: newUrl
61 .then(async (response) => {
62 if (!response.ok) {
63 alert((response.status === 409)
64 ? await response.text()
65 : "QBT_TR(Unable to update URL)QBT_TR[CONTEXT=RSSWidget]");
66 $("submitButton").disabled = false;
67 return;
70 window.parent.qBittorrent.Rss.updateRssFeedList();
71 window.parent.qBittorrent.Client.closeFrameWindow(window);
72 });
73 });
74 });
75 </script>
76 </head>
78 <body>
79 <div style="padding: 10px 10px 0px 10px;">
80 <label for="url" style="font-weight: bold;">QBT_TR(Feed URL:)QBT_TR[CONTEXT=RSSWidget]</label>
81 <input type="text" id="url" style="width: 320px;">
82 <div style="text-align: center; padding-top: 10px;">
83 <input type="button" value="QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" id="submitButton">
84 </div>
85 </div>
86 </body>
88 </html>