From 4846b0ec28a475dc36d1eb80c1a0436cec34b7ba Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Tue, 18 Jul 2017 22:06:38 -0400 Subject: [PATCH] Use single quotes for char. Use case insensitive compare. Swap conditionals --- src/webui/webapplication.cpp | 34 ++++++++++----------- src/webui/www/public/scripts/contextmenu.js | 6 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index 559f5abd6..f4eb9e410 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -596,7 +596,7 @@ void WebApplication::action_command_getTorrentsUpLimit() { CHECK_URI(0); CHECK_PARAMETERS("hashes"); - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); print(btjson::getTorrentsRatesLimits(hashes, false), Http::CONTENT_TYPE_JSON); } @@ -604,7 +604,7 @@ void WebApplication::action_command_getTorrentsDlLimit() { CHECK_URI(0); CHECK_PARAMETERS("hashes"); - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); print(btjson::getTorrentsRatesLimits(hashes, true), Http::CONTENT_TYPE_JSON); } @@ -617,7 +617,7 @@ void WebApplication::action_command_setTorrentsUpLimit() if (limit == 0) limit = -1; - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); foreach (const QString &hash, hashes) { BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (torrent) @@ -634,7 +634,7 @@ void WebApplication::action_command_setTorrentsDlLimit() if (limit == 0) limit = -1; - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); foreach (const QString &hash, hashes) { BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (torrent) @@ -660,7 +660,7 @@ void WebApplication::action_command_toggleSequentialDownload() { CHECK_URI(0); CHECK_PARAMETERS("hashes"); - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); foreach (const QString &hash, hashes) { BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (torrent) @@ -672,7 +672,7 @@ void WebApplication::action_command_toggleFirstLastPiecePrio() { CHECK_URI(0); CHECK_PARAMETERS("hashes"); - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); foreach (const QString &hash, hashes) { BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (torrent) @@ -685,7 +685,7 @@ void WebApplication::action_command_setSuperSeeding() CHECK_URI(0); CHECK_PARAMETERS("hashes" << "value"); bool value = request().posts["value"] == "true"; - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); foreach (const QString &hash, hashes) { BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (torrent) @@ -698,7 +698,7 @@ void WebApplication::action_command_setForceStart() CHECK_URI(0); CHECK_PARAMETERS("hashes" << "value"); bool value = request().posts["value"] == "true"; - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); foreach (const QString &hash, hashes) { BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (torrent) @@ -710,7 +710,7 @@ void WebApplication::action_command_delete() { CHECK_URI(0); CHECK_PARAMETERS("hashes"); - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); foreach (const QString &hash, hashes) BitTorrent::Session::instance()->deleteTorrent(hash, false); } @@ -719,7 +719,7 @@ void WebApplication::action_command_deletePerm() { CHECK_URI(0); CHECK_PARAMETERS("hashes"); - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); foreach (const QString &hash, hashes) BitTorrent::Session::instance()->deleteTorrent(hash, true); } @@ -734,7 +734,7 @@ void WebApplication::action_command_increasePrio() return; } - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); BitTorrent::Session::instance()->increaseTorrentsPriority(hashes); } @@ -748,7 +748,7 @@ void WebApplication::action_command_decreasePrio() return; } - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); BitTorrent::Session::instance()->decreaseTorrentsPriority(hashes); } @@ -762,7 +762,7 @@ void WebApplication::action_command_topPrio() return; } - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); BitTorrent::Session::instance()->topTorrentsPriority(hashes); } @@ -776,7 +776,7 @@ void WebApplication::action_command_bottomPrio() return; } - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); BitTorrent::Session::instance()->bottomTorrentsPriority(hashes); } @@ -828,13 +828,13 @@ void WebApplication::action_command_setAutoTMM() CHECK_URI(0); CHECK_PARAMETERS("hashes" << "enable"); - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); QString enableStr = request().posts["enable"]; foreach (const QString &hash, hashes) { BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); if (torrent) - torrent->setAutoTMMEnabled(enableStr == "true"); + torrent->setAutoTMMEnabled(QString::compare(enableStr, "true", Qt::CaseInsensitive) == 0); } } @@ -853,7 +853,7 @@ void WebApplication::action_command_setCategory() CHECK_URI(0); CHECK_PARAMETERS("hashes" << "category"); - QStringList hashes = request().posts["hashes"].split("|"); + QStringList hashes = request().posts["hashes"].split('|'); QString category = request().posts["category"].trimmed(); foreach (const QString &hash, hashes) { diff --git a/src/webui/www/public/scripts/contextmenu.js b/src/webui/www/public/scripts/contextmenu.js index 9036a8afc..f8f559f61 100644 --- a/src/webui/www/public/scripts/contextmenu.js +++ b/src/webui/www/public/scripts/contextmenu.js @@ -287,10 +287,10 @@ var TorrentsTableContextMenu = new Class({ else there_are_force_start = true; - if (data['auto_tmm'] != true) - all_are_auto_tmm = false; - else + if (data['auto_tmm'] === true) there_are_auto_tmm = true; + else + all_are_auto_tmm = false; }); show_seq_dl = true;