From b2f951a2695e96d12b58b9cb56a5cb7b2025627b Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 19 Aug 2020 15:12:55 +0800 Subject: [PATCH 1/4] Remove duplicate code --- src/webui/www/private/views/preferences.html | 1 - 1 file changed, 1 deletion(-) diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index cc2d81d08..5a0689b34 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -2115,7 +2115,6 @@ } settings.set('max_ratio_enabled', $('max_ratio_checkbox').getProperty('checked')); settings.set('max_ratio', max_ratio); - settings.set('max_ratio_act', $('max_ratio_act').getProperty('value').toInt()); let max_seeding_time = -1; if ($('max_seeding_time_checkbox').getProperty('checked')) { From f7f0a27d766fa3e4dc5561b0891361a2a49867d0 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 19 Aug 2020 15:25:51 +0800 Subject: [PATCH 2/4] Clean up coding style --- src/webui/www/private/views/preferences.html | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 5a0689b34..8b2e7c0f9 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -1738,15 +1738,9 @@ // Share Limiting $('max_ratio_checkbox').setProperty('checked', pref.max_ratio_enabled); - if (pref.max_ratio_enabled) - $('max_ratio_value').setProperty('value', pref.max_ratio); - else - $('max_ratio_value').setProperty('value', 1); + $('max_ratio_value').setProperty('value', (pref.max_ratio_enabled ? pref.max_ratio : 1)); $('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); + $('max_seeding_time_value').setProperty('value', (pref.max_seeding_time_enabled ? pref.max_seeding_time.toInt() : 1440)); let maxRatioAct = 0; switch (pref.max_ratio_act.toInt()) { case 0: // Pause @@ -2108,7 +2102,7 @@ let max_ratio = -1; if ($('max_ratio_checkbox').getProperty('checked')) { max_ratio = $('max_ratio_value').getProperty('value'); - if (isNaN(max_ratio) || max_ratio < 0 || max_ratio > 9998) { + if (isNaN(max_ratio) || (max_ratio < 0) || (max_ratio > 9998)) { alert("QBT_TR(Share ratio limit must be between 0 and 9998.)QBT_TR[CONTEXT=HttpServer]"); return; } @@ -2119,7 +2113,7 @@ let 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) { + 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; } From ed2756b88550885cc1d35df1565d273f4ce6c528 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 19 Aug 2020 15:27:23 +0800 Subject: [PATCH 3/4] Convert to the proper type --- src/webui/www/private/views/preferences.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 8b2e7c0f9..4052f5816 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -2101,7 +2101,7 @@ // Share Ratio Limiting let max_ratio = -1; if ($('max_ratio_checkbox').getProperty('checked')) { - max_ratio = $('max_ratio_value').getProperty('value'); + max_ratio = $('max_ratio_value').getProperty('value').toFloat(); if (isNaN(max_ratio) || (max_ratio < 0) || (max_ratio > 9998)) { alert("QBT_TR(Share ratio limit must be between 0 and 9998.)QBT_TR[CONTEXT=HttpServer]"); return; From 8869dc543fc1f02197d40934a1724f8b6dc147c3 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 19 Aug 2020 15:36:46 +0800 Subject: [PATCH 4/4] Fix seeding time checkbox placement in WebUI --- src/webui/www/private/views/preferences.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 4052f5816..fd9542083 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -565,8 +565,8 @@ - + QBT_TR(minutes)QBT_TR[CONTEXT=OptionsDialog]