WebUI: Remove redundant event listener
[qBittorrent.git] / src / webui / www / private / newrule.html
blob18f03a1542591326f6a3de58d32e9f2109a871c6
1 <!DOCTYPE html>
2 <html lang="${LANG}" class="dark">
4 <head>
5 <meta charset="UTF-8">
6 <title>QBT_TR(New rule name)QBT_TR[CONTEXT=AutomatedRssDownloader]</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 $("name").focus();
31 $("submitButton").addEventListener("click", (e) => {
32 e.preventDefault();
33 e.stopPropagation();
35 // check field
36 const name = $("name").value.trim();
37 if (name === "") {
38 alert("QBT_TR(Name cannot be empty)QBT_TR[CONTEXT=HttpServer]");
39 return;
41 $("submitButton").disabled = true;
43 fetch("api/v2/rss/setRule", {
44 method: "POST",
45 body: new URLSearchParams({
46 ruleName: name,
47 ruleDef: "{}"
50 .then((response) => {
51 if (!response.ok)
52 return;
54 window.parent.qBittorrent.RssDownloader.updateRulesList();
55 window.parent.qBittorrent.Client.closeFrameWindow(window);
56 });
57 });
58 });
59 </script>
60 </head>
62 <body>
63 <div style="padding: 10px 10px 0px 10px;">
64 <label for="name">QBT_TR(Please type the name of the new download rule.)QBT_TR[CONTEXT=AutomatedRssDownloader]</label>
65 <input type="text" id="name" style="width: 320px;">
66 <div style="text-align: center; padding-top: 10px;">
67 <input type="button" value="QBT_TR(OK)QBT_TR[CONTEXT=HttpServer]" id="submitButton">
68 </div>
69 </div>
70 </body>
72 </html>