2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2019 Thomas Piccirello <thomas.piccirello@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * In addition, as a special exception, the copyright holders give permission to
20 * link this program with the OpenSSL project's "OpenSSL" library (or with
21 * modified versions of it that use the same license as the "OpenSSL" library),
22 * and distribute the linked executables. You must obey the GNU General Public
23 * License in all respects for all of the code used other than "OpenSSL". If you
24 * modify file(s), you may extend this exception to your version of the file(s),
25 * but you are not obligated to do so. If you do not wish to do so, delete this
26 * exception statement from your version.
32 addUpLimitSlider: function(hashes
) {
33 if ($("uplimitSliderarea")) {
34 // Get global upload limit
37 url
: "api/v2/transfer/uploadLimit",
40 onSuccess: function(data
) {
42 const tmp
= data
.toInt();
44 maximum
= tmp
/ 1024.0;
47 if (hashes
[0] === "global")
53 // Get torrents upload limit
55 if (hashes
[0] === "global") {
56 let up_limit
= maximum
;
60 new Slider($("uplimitSliderarea"), $("uplimitSliderknob"), {
63 initialStep
: up_limit
.round(),
64 onChange: function(pos
) {
66 $("uplimitUpdatevalue").value
= pos
;
67 $("upLimitUnit").style
.visibility
= "visible";
70 $("uplimitUpdatevalue").value
= "∞";
71 $("upLimitUnit").style
.visibility
= "hidden";
77 $("uplimitUpdatevalue").value
= "∞";
78 $("upLimitUnit").style
.visibility
= "hidden";
81 $("uplimitUpdatevalue").value
= up_limit
.round();
82 $("upLimitUnit").style
.visibility
= "visible";
87 url
: "api/v2/torrents/uploadLimit",
90 hashes
: hashes
.join("|")
92 onSuccess: function(data
) {
94 let up_limit
= data
[hashes
[0]];
95 for (const key
in data
) {
96 if (up_limit
!== data
[key
]) {
103 new Slider($("uplimitSliderarea"), $("uplimitSliderknob"), {
106 initialStep
: (up_limit
/ 1024.0).round(),
107 onChange: function(pos
) {
109 $("uplimitUpdatevalue").value
= pos
;
110 $("upLimitUnit").style
.visibility
= "visible";
113 $("uplimitUpdatevalue").value
= "∞";
114 $("upLimitUnit").style
.visibility
= "hidden";
119 if (up_limit
=== 0) {
120 $("uplimitUpdatevalue").value
= "∞";
121 $("upLimitUnit").style
.visibility
= "hidden";
124 $("uplimitUpdatevalue").value
= (up_limit
/ 1024.0).round();
125 $("upLimitUnit").style
.visibility
= "visible";
136 addDlLimitSlider: function(hashes
) {
137 if ($("dllimitSliderarea")) {
138 // Get global upload limit
141 url
: "api/v2/transfer/downloadLimit",
144 onSuccess: function(data
) {
146 const tmp
= data
.toInt();
148 maximum
= tmp
/ 1024.0;
151 if (hashes
[0] === "global")
157 // Get torrents download limit
159 if (hashes
[0] === "global") {
160 let dl_limit
= maximum
;
164 new Slider($("dllimitSliderarea"), $("dllimitSliderknob"), {
167 initialStep
: dl_limit
.round(),
168 onChange: function(pos
) {
170 $("dllimitUpdatevalue").value
= pos
;
171 $("dlLimitUnit").style
.visibility
= "visible";
174 $("dllimitUpdatevalue").value
= "∞";
175 $("dlLimitUnit").style
.visibility
= "hidden";
180 if (dl_limit
=== 0) {
181 $("dllimitUpdatevalue").value
= "∞";
182 $("dlLimitUnit").style
.visibility
= "hidden";
185 $("dllimitUpdatevalue").value
= dl_limit
.round();
186 $("dlLimitUnit").style
.visibility
= "visible";
191 url
: "api/v2/torrents/downloadLimit",
194 hashes
: hashes
.join("|")
196 onSuccess: function(data
) {
198 let dl_limit
= data
[hashes
[0]];
199 for (const key
in data
) {
200 if (dl_limit
!== data
[key
]) {
207 new Slider($("dllimitSliderarea"), $("dllimitSliderknob"), {
210 initialStep
: (dl_limit
/ 1024.0).round(),
211 onChange: function(pos
) {
213 $("dllimitUpdatevalue").value
= pos
;
214 $("dlLimitUnit").style
.visibility
= "visible";
217 $("dllimitUpdatevalue").value
= "∞";
218 $("dlLimitUnit").style
.visibility
= "hidden";
223 if (dl_limit
=== 0) {
224 $("dllimitUpdatevalue").value
= "∞";
225 $("dlLimitUnit").style
.visibility
= "hidden";
228 $("dllimitUpdatevalue").value
= (dl_limit
/ 1024.0).round();
229 $("dlLimitUnit").style
.visibility
= "visible";