WebUI: migrate to fetch API
[qBittorrent.git] / src / webui / www / private / edittracker.html
blobd8591ef5587bf5d8281cc8cb57fa29f6873c3871
1 <!DOCTYPE html>
2 <html lang="${LANG}" class="dark">
4 <head>
5 <meta charset="UTF-8">
6 <title>QBT_TR(Tracker editing)QBT_TR[CONTEXT=TrackerListWidget]</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 $("editTrackerButton").click();
21 break;
22 case "Escape":
23 event.preventDefault();
24 window.parent.qBittorrent.Client.closeFrameWindow(window);
25 break;
27 });
29 const currentUrl = new URI().getData("url");
30 if (!currentUrl)
31 return;
33 $("trackerUrl").value = currentUrl;
34 $("trackerUrl").focus();
36 $("editTrackerButton").addEventListener("click", (e) => {
37 e.preventDefault();
38 e.stopPropagation();
40 fetch("api/v2/torrents/editTracker", {
41 method: "POST",
42 body: new URLSearchParams({
43 "hash": new URI().getData("hash"),
44 "origUrl": currentUrl,
45 "newUrl": $("trackerUrl").value
48 .then((response) => {
49 if (!response.ok)
50 return;
52 window.parent.qBittorrent.Client.closeFrameWindow(window);
53 });
54 });
55 });
56 </script>
57 </head>
59 <body>
60 <div style="text-align: center;">
61 <br>
62 <label for="trackerUrl">QBT_TR(Tracker URL:)QBT_TR[CONTEXT=TrackerListWidget]</label>
63 <div style="text-align: center; padding-top: 10px;">
64 <input type="text" id="trackerUrl" style="width: 90%;">
65 </div>
66 <br>
67 <input type="button" value="QBT_TR(Edit)QBT_TR[CONTEXT=HttpServer]" id="editTrackerButton">
68 </div>
69 </body>
71 </html>