WebUI: migrate to fetch API
[qBittorrent.git] / src / webui / www / private / uploadlimit.html
blobe0667a3c81c055273802a7170cdeda1cdaadee1d
1 <!DOCTYPE html>
2 <html lang="${LANG}" class="dark">
4 <head>
5 <meta charset="UTF-8">
6 <title>QBT_TR(Torrent Upload Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]</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/lib/mocha.min.js"></script>
11 <script src="scripts/localpreferences.js?v=${CACHEID}"></script>
12 <script src="scripts/color-scheme.js?v=${CACHEID}"></script>
13 <script src="scripts/speedslider.js?v=${CACHEID}"></script>
14 </head>
16 <body>
17 <div style="padding-top: 10px; width: 100%; text-align: center; margin: 0 auto; overflow: hidden">
18 <div id="uplimitSlider" class="slider">
19 <div id="uplimitUpdate" class="update">
20 <label for="uplimitUpdatevalue">QBT_TR(Upload limit:)QBT_TR[CONTEXT=PropertiesWidget]</label>
21 <input type="text" id="uplimitUpdatevalue" size="6" placeholder="∞" style="text-align: center;">
22 <span id="upLimitUnit">QBT_TR(KiB/s)QBT_TR[CONTEXT=SpeedLimitDialog]</span>
23 </div>
24 <div class="sliderWrapper">
25 <div id="uplimitSliderknob" class="sliderknob"></div>
26 <div id="uplimitSliderarea" class="sliderarea"></div>
27 </div>
28 <div class="clear"></div>
29 </div>
30 <input type="button" id="applyButton" value="QBT_TR(Apply)QBT_TR[CONTEXT=HttpServer]" onclick="setUpLimit()">
31 </div>
33 <script>
34 "use strict";
36 window.addEventListener("keydown", (event) => {
37 switch (event.key) {
38 case "Enter":
39 event.preventDefault();
40 $("applyButton").click();
41 break;
42 case "Escape":
43 event.preventDefault();
44 window.parent.qBittorrent.Client.closeFrameWindow(window);
45 break;
47 });
49 const hashes = new URI().getData("hashes").split("|");
50 const setUpLimit = () => {
51 const limit = Number($("uplimitUpdatevalue").value) * 1024;
52 if (hashes[0] === "global") {
53 fetch("api/v2/transfer/setUploadLimit", {
54 method: "POST",
55 body: new URLSearchParams({
56 "limit": limit
59 .then((response) => {
60 if (!response.ok)
61 return;
63 window.parent.updateMainData();
64 window.parent.qBittorrent.Client.closeFrameWindow(window);
65 });
67 else {
68 fetch("api/v2/torrents/setUploadLimit", {
69 method: "POST",
70 body: new URLSearchParams({
71 "hashes": hashes.join("|"),
72 "limit": limit
75 .then((response) => {
76 if (!response.ok)
77 return;
79 window.parent.qBittorrent.Client.closeFrameWindow(window);
80 });
84 $("uplimitUpdatevalue").focus();
86 MochaUI.addUpLimitSlider(hashes);
87 </script>
88 </body>
90 </html>