Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make throttle an optional dependency for extratio #2685

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions plugins/extratio/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,27 @@ plugin.loadRules = function( rle )
if(fltThrottle.length)
{
$('#dst_throttle option').remove();
fltThrottle.append("<option value=''>"+theUILang.dontSet+"</option>");
fltThrottle.append(
$("<option>").val("").text(theUILang.dontSet),
);
for(var i=0; i<theWebUI.maxThrottle; i++)
if(theWebUI.isCorrectThrottle(i))
fltThrottle.append("<option value='thr_"+i+"'>"+theWebUI.throttles[i].name+"</option>");
fltThrottle.append(
$("<option>").val("thr_" + i).text(theWebUI.throttles[i].name),
);
}
var fltRatio = $('#dst_ratio');
if(fltRatio.length)
{
$('#dst_ratio option').remove();
fltRatio.append("<option value=''>"+theUILang.dontSet+"</option>");
fltRatio.append(
$("<option>").val("").text(theUILang.dontSet),
);
for(var i=0; i<theWebUI.maxRatio; i++)
if(theWebUI.isCorrectRatio(i))
fltRatio.append("<option value='rat_"+i+"'>"+theWebUI.ratios[i].name+"</option>");
fltRatio.append(
$("<option>").val("rat_" + i).text(theWebUI.ratios[i].name),
);
}
plugin.curRule = null;
var list = $("#rlsul");
Expand All @@ -74,10 +82,14 @@ plugin.loadRules = function( rle )
var f = plugin.rules[i];
if(plugin.maxRuleNo<f.no)
plugin.maxRuleNo = f.no;
list.append( $("<li>").html("<input type='checkbox' id='_rre"+i+"'/><input type='text' class='TextboxNormal' onfocus=\"theWebUI.selectRatioRule(this);\" id='_rrn"+i+"'/>"));
$("#_rrn"+i).val(f.name);
if(f.enabled)
$("#_rre"+i).prop("checked",true);
list.append(
$("<li>").append(
$("<input>").attr({type: "checkbox", id: "_rre" + i}).prop("checked", f.enabled),
$("<input>").attr(
{type: "text", id: "_rrn" + i, onfocus: "theWebUI.selectRatioRule(this);"}
).addClass("TextboxNormal").val(f.name),
),
);
}
for(var i=0; i<plugin.rules.length; i++)
{
Expand Down Expand Up @@ -214,15 +226,16 @@ rTorrentStub.prototype.setratiorules = function()
{
this.content = "mode=setrules";
plugin.storeRuleParams();
const thrtlInstalled = thePlugins.isInstalled("throttle");
for(var i=0; i<plugin.rules.length; i++)
{
var rle = plugin.rules[i];
var enabled = $("#_rre"+i).prop("checked") ? 1 : 0;
var name = $("#_rrn"+i).val();
this.content = this.content+"&name="+encodeURIComponent(name)+"&pattern="+encodeURIComponent(rle.pattern)+"&enabled="+enabled+
"&reason="+rle.reason+
"&channel="+rle.channel+"&ratio="+rle.ratio+
"&no="+rle.no;
this.content += "&name="+encodeURIComponent(name) + "&pattern=" + encodeURIComponent(rle.pattern) +
"&enabled=" + enabled + "&reason=" + rle.reason +
"&ratio=" + rle.ratio + "&no="+rle.no;
thrtlInstalled && (this.content += "&channel=" + rle.channel);
}
this.contentType = "application/x-www-form-urlencoded";
this.mountPoint = "plugins/extratio/action.php";
Expand Down Expand Up @@ -347,7 +360,7 @@ plugin.onLangLoaded = function()
$("<select>").attr({id: "dst_ratio"}).addClass("flex-grow-1"),
),
),
$("<div>").addClass("row align-items-center").append(
thePlugins.isInstalled("throttle") && $("<div>").addClass("row align-items-center").append(
$("<div>").addClass("col-md-6 d-flex justify-content-md-end").append(
$("<label>").attr({for: "dst_throttle"}).text(theUILang.setChannelTo),
),
Expand Down
2 changes: 1 addition & 1 deletion plugins/extratio/plugin.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugin.description: This plugin extends the functionality of the ratio plugin.
plugin.author: Novik
plugin.runlevel: 12
plugin.version: 4.3
plugin.dependencies: ratio,throttle
plugin.dependencies: ratio
php.extensions.error: json
rtorrent.version: 0.8.6
plugin.help: https://github.com/Novik/ruTorrent/wiki/PluginExtRatio