WebUI: Remove redundant event listener
[qBittorrent.git] / src / webui / www / private / editwebseed.html
blob853fe1179828aac4fad037379a7c37fde6121b84
1 <!DOCTYPE html>
2 <html lang="${LANG}" class="dark">
4 <head>
5 <meta charset="UTF-8">
6 <title>QBT_TR(Edit web seed)QBT_TR[CONTEXT=HttpServer]</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>
13 "use strict";
15 window.addEventListener("DOMContentLoaded", () => {
16 window.addEventListener("keydown", (event) => {
17 switch (event.key) {
18 case "Enter":
19 event.preventDefault();
20 $("editWebSeedButton").click();
21 break;
22 case "Escape":
23 event.preventDefault();
24 window.parent.qBittorrent.Client.closeFrameWindow(window);
25 break;
27 });
29 const origUrl = new URI().getData("url");
30 $("url").value = decodeURIComponent(origUrl);
31 $("url").focus();
33 $("editWebSeedButton").addEventListener("click", (e) => {
34 e.stopPropagation();
36 fetch("api/v2/torrents/editWebSeed", {
37 method: "POST",
38 body: new URLSearchParams({
39 hash: new URI().getData("hash"),
40 origUrl: origUrl,
41 newUrl: encodeURIComponent($("url").value.trim())
44 .then((response) => {
45 if (!response.ok)
46 return;
48 window.parent.qBittorrent.Client.closeFrameWindow(window);
49 });
50 });
51 });
52 </script>
53 </head>
55 <body>
56 <div style="text-align: center;">
57 <br>
58 <label for="url">QBT_TR(Web seed URL:)QBT_TR[CONTEXT=PropertiesWidget]</label>
59 <div style="text-align: center; padding-top: 10px;">
60 <input type="text" id="url" style="width: 90%;">
61 </div>
62 <br>
63 <input type="button" value="QBT_TR(Edit)QBT_TR[CONTEXT=HttpServer]" id="editWebSeedButton">
64 </div>
65 </body>
67 </html>