Implemented share limit by seeding time

This commit is contained in:
Naikel Aparicio
2016-02-07 13:01:50 -04:30
parent f4a6242711
commit 9ba00d7035
16 changed files with 661 additions and 162 deletions

View File

@@ -307,14 +307,36 @@
<fieldset class="settings">
<legend>QBT_TR(Share Ratio Limiting)QBT_TR[CONTEXT=OptionsDialog]</legend>
<input type="checkbox" id="max_ratio_checkbox" onClick="updateMaxRatioEnabled();"/>
<table>
<tr>
<td>
<input type="checkbox" id="max_ratio_checkbox" onClick="updateMaxRatioTimeEnabled();"/>
<label for="max_ratio_checkbox">QBT_TR(Seed torrents until their ratio reaches)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="max_ratio_value" style="width: 4em;"/>
</td>
<tr>
<td>
<input type="checkbox" id="max_seeding_time_checkbox" onClick="updateMaxRatioTimeEnabled();"/>
<label for="max_seeding_time_checkbox">QBT_TR(Seed torrents until their seeding time reaches)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="max_seeding_time_value" style="width: 4em;"/> QBT_TR(minutes)QBT_TR[CONTEXT=OptionsDialog]
</td>
</tr>
<tr>
<td style="text-align: right;">
QBT_TR(then)QBT_TR[CONTEXT=OptionsDialog]
</td>
<td>
<select id="max_ratio_act">
<option value="0">QBT_TR(Pause them)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="1">QBT_TR(Remove them)QBT_TR[CONTEXT=OptionsDialog]</option>
</select>
</td>
</tr>
</table>
</fieldset>
<fieldset class="settings">
@@ -724,12 +746,20 @@ updateQueueingSystem = function() {
}
}
updateMaxRatioEnabled = function() {
updateMaxRatioTimeEnabled = function() {
if($('max_ratio_checkbox').getProperty('checked')) {
$('max_ratio_value').setProperty('disabled', false);
$('max_ratio_act').setProperty('disabled', false);
} else {
$('max_ratio_value').setProperty('disabled', true);
}
if($('max_seeding_time_checkbox').getProperty('checked')) {
$('max_seeding_time_value').setProperty('disabled', false);
} else {
$('max_seeding_time_value').setProperty('disabled', true);
}
if($('max_ratio_checkbox').getProperty('checked') || $('max_seeding_time_checkbox').getProperty('checked')) {
$('max_ratio_act').setProperty('disabled', false);
} else {
$('max_ratio_act').setProperty('disabled', true);
}
}
@@ -992,7 +1022,7 @@ loadPreferences = function() {
$('dont_count_slow_torrents_checkbox').setProperty('checked', pref.dont_count_slow_torrents);
updateQueueingSystem();
// Share Ratio Limiting
// Share Limiting
$('max_ratio_checkbox').setProperty('checked', pref.max_ratio_enabled);
if (pref.max_ratio_enabled)
$('max_ratio_value').setProperty('value', pref.max_ratio);
@@ -1000,7 +1030,14 @@ loadPreferences = function() {
$('max_ratio_value').setProperty('value', 1);
var max_ratio_act = pref.max_ratio_act.toInt();
$('max_ratio_act').getChildren('option')[max_ratio_act].setAttribute('selected', '');
updateMaxRatioEnabled();
$('max_seeding_time_checkbox').setProperty('checked', pref.max_seeding_time_enabled);
if (pref.max_seeding_time_enabled)
$('max_seeding_time_value').setProperty('value', pref.max_seeding_time.toInt());
else
$('max_seeding_time_value').setProperty('value', 1440);
var max_ratio_act = pref.max_ratio_act.toInt();
$('max_ratio_act').getChildren('option')[max_ratio_act].setAttribute('selected', '');
updateMaxRatioTimeEnabled();
// Add trackers
$('add_trackers_checkbox').setProperty('checked', pref.add_trackers_enabled);
@@ -1258,6 +1295,18 @@ applyPreferences = function() {
settings.set('max_ratio', max_ratio);
settings.set('max_ratio_act', $('max_ratio_act').getProperty('value').toInt());
var max_seeding_time = -1;
if($('max_seeding_time_checkbox').getProperty('checked')) {
max_seeding_time = $('max_seeding_time_value').getProperty('value').toInt();
if(isNaN(max_seeding_time) || max_seeding_time < 0 || max_seeding_time > 525600) {
alert("QBT_TR(Seeding time limit must be between 0 and 525600 minutes.)QBT_TR[CONTEXT=HttpServer]");
return;
}
}
settings.set('max_seeding_time_enabled', $('max_seeding_time_checkbox').getProperty('checked'));
settings.set('max_seeding_time', max_seeding_time);
settings.set('max_ratio_act', $('max_ratio_act').getProperty('value').toInt());
// Add trackers
settings.set('add_trackers_enabled', $('add_trackers_checkbox').getProperty('checked'));
settings.set('add_trackers', $('add_trackers_textarea').getProperty('value'));