From ba32525b450292434fe17579120a361beaf9c53c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 30 Nov 2018 18:35:32 +0800 Subject: [PATCH] Fix errors from using strict mode --- src/webui/www/private/downloadlimit.html | 2 +- .../www/private/preferences_content.html | 66 +++++++++---------- src/webui/www/private/scripts/client.js | 10 +-- src/webui/www/private/scripts/download.js | 8 +-- src/webui/www/private/scripts/mocha-init.js | 37 ++++++++++- src/webui/www/private/scripts/prop-files.js | 2 +- .../www/private/scripts/prop-trackers.js | 2 +- .../www/private/scripts/prop-webseeds.js | 2 +- src/webui/www/private/uploadlimit.html | 2 +- 9 files changed, 81 insertions(+), 50 deletions(-) diff --git a/src/webui/www/private/downloadlimit.html b/src/webui/www/private/downloadlimit.html index b10fdd67f..52b8eaaf5 100644 --- a/src/webui/www/private/downloadlimit.html +++ b/src/webui/www/private/downloadlimit.html @@ -25,7 +25,7 @@ 'use strict'; var hashes = new URI().getData('hashes').split('|'); - setDlLimit = function() { + var setDlLimit = function() { var limit = $("dllimitUpdatevalue").value.toInt() * 1024; if (hashes[0] == "global") { new Request({ diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index 5eb2fa2b3..13a70ac64 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -819,12 +819,12 @@ // Downloads tab var WatchedFoldersTable = new HtmlTable($("watched_folders_tab")); - updateTempDirEnabled = function() { + var updateTempDirEnabled = function() { var isTempDirEnabled = $('temppath_checkbox').getProperty('checked'); $('temppath_text').setProperty('disabled', !isTempDirEnabled); }; - addWatchFolder = function() { + var addWatchFolder = function() { var new_folder = $('new_watch_folder_txt').getProperty('value').trim(); if (new_folder.length <= 0) return; @@ -844,7 +844,7 @@ $('new_watch_folder_other_txt').setProperty('value', text); }; - changeWatchFolderSelect = function(item) { + var changeWatchFolderSelect = function(item) { if (item.value == "other") { item.nextElementSibling.hidden = false; item.nextElementSibling.value = 'QBT_TR(Type folder here)QBT_TR[CONTEXT=HttpServer]'; @@ -857,7 +857,7 @@ } }; - pushWatchFolder = function(pos, folder, sel, other) { + var pushWatchFolder = function(pos, folder, sel, other) { var myinput = ""; var disableInput = (sel != "other"); var mycb = "
" @@ -877,7 +877,7 @@ $('cb_watch_txt_' + pos).setProperty('value', other); }; - getWatchedFolders = function() { + var getWatchedFolders = function() { var nb_folders = $("watched_folders_tab").getChildren("tbody")[0].getChildren("tr").length; var folders = new Hash(); for (var i = 0; i < nb_folders; ++i) { @@ -897,17 +897,17 @@ return folders; }; - updateExportDirEnabled = function() { + var updateExportDirEnabled = function() { var isExportDirEnabled = $('exportdir_checkbox').getProperty('checked'); $('exportdir_text').setProperty('disabled', !isExportDirEnabled); }; - updateExportDirFinEnabled = function() { + var updateExportDirFinEnabled = function() { var isExportDirFinEnabled = $('exportdirfin_checkbox').getProperty('checked'); $('exportdirfin_text').setProperty('disabled', !isExportDirFinEnabled); }; - updateMailNotification = function() { + var updateMailNotification = function() { var isMailNotificationEnabled = $('mail_notification_checkbox').getProperty('checked'); $('src_email_txt').setProperty('disabled', !isMailNotificationEnabled); $('dest_email_txt').setProperty('disabled', !isMailNotificationEnabled); @@ -921,39 +921,39 @@ } }; - updateMailAuthSettings = function() { + var updateMailAuthSettings = function() { var isMailAuthEnabled = $('mail_auth_checkbox').getProperty('checked'); $('mail_username_text').setProperty('disabled', !isMailAuthEnabled); $('mail_password_text').setProperty('disabled', !isMailAuthEnabled); }; - updateAutoRun = function() { + var updateAutoRun = function() { var isAutoRunEnabled = $('autorun_checkbox').getProperty('checked'); $('autorunProg_txt').setProperty('disabled', !isAutoRunEnabled); }; // Connection tab - updateMaxConnecEnabled = function() { + var updateMaxConnecEnabled = function() { var isMaxConnecEnabled = $('max_connec_checkbox').getProperty('checked'); $('max_connec_value').setProperty('disabled', !isMaxConnecEnabled); }; - updateMaxConnecPerTorrentEnabled = function() { + var updateMaxConnecPerTorrentEnabled = function() { var isMaxConnecPerTorrentEnabled = $('max_connec_per_torrent_checkbox').getProperty('checked'); $('max_connec_per_torrent_value').setProperty('disabled', !isMaxConnecPerTorrentEnabled); }; - updateMaxUploadsEnabled = function() { + var updateMaxUploadsEnabled = function() { var isMaxUploadsEnabled = $('max_uploads_checkbox').getProperty('checked'); $('max_uploads_value').setProperty('disabled', !isMaxUploadsEnabled); }; - updateMaxUploadsPerTorrentEnabled = function() { + var updateMaxUploadsPerTorrentEnabled = function() { var isMaxUploadsPerTorrentEnabled = $('max_uploads_per_torrent_checkbox').getProperty('checked'); $('max_uploads_per_torrent_value').setProperty('disabled', !isMaxUploadsPerTorrentEnabled); }; - updatePeerProxySettings = function() { + var updatePeerProxySettings = function() { var isPeerProxyTypeSelected = $('peer_proxy_type_select').getProperty('value') != "none"; $('peer_proxy_host_text').setProperty('disabled', !isPeerProxyTypeSelected); $('peer_proxy_port_value').setProperty('disabled', !isPeerProxyTypeSelected); @@ -979,19 +979,19 @@ updateForceProxySettings(); }; - updateForceProxySettings = function() { + var updateForceProxySettings = function() { var isForceProxyEnabled = (!$('force_proxy_checkbox').getProperty('disabled')) && ($('force_proxy_checkbox').getProperty('checked')); $('upnp_checkbox').setProperty('disabled', isForceProxyEnabled); $('lsd_checkbox').setProperty('disabled', isForceProxyEnabled); }; - updatePeerProxyAuthSettings = function() { + var updatePeerProxyAuthSettings = function() { var isPeerProxyAuthEnabled = $('peer_proxy_auth_checkbox').getProperty('checked'); $('peer_proxy_username_text').setProperty('disabled', !isPeerProxyAuthEnabled); $('peer_proxy_password_text').setProperty('disabled', !isPeerProxyAuthEnabled); }; - updateFilterSettings = function() { + var updateFilterSettings = function() { var isIPFilterEnabled = $('ipfilter_enabled_checkbox').getProperty('checked'); $('ipfilter_text').setProperty('disabled', !isIPFilterEnabled); $('ipfilter_trackers_checkbox').setProperty('disabled', !isIPFilterEnabled); @@ -999,7 +999,7 @@ }; // Speed tab - updateSchedulingEnabled = function() { + var updateSchedulingEnabled = function() { var isLimitSchedulingEnabled = $('limit_sheduling_checkbox').getProperty('checked'); $('schedule_from_hour').setProperty('disabled', !isLimitSchedulingEnabled); $('schedule_from_min').setProperty('disabled', !isLimitSchedulingEnabled); @@ -1009,7 +1009,7 @@ }; // Bittorrent tab - updateQueueingSystem = function() { + var updateQueueingSystem = function() { var isQueueingEnabled = $('queueing_checkbox').getProperty('checked'); $('max_active_dl_value').setProperty('disabled', !isQueueingEnabled); $('max_active_up_value').setProperty('disabled', !isQueueingEnabled); @@ -1018,14 +1018,14 @@ updateSlowTorrentsSettings(); }; - updateSlowTorrentsSettings = function() { + var updateSlowTorrentsSettings = function() { var isDontCountSlowTorrentsEnabled = (!$('dont_count_slow_torrents_checkbox').getProperty('disabled')) && $('dont_count_slow_torrents_checkbox').getProperty('checked'); $('dl_rate_threshold').setProperty('disabled', !isDontCountSlowTorrentsEnabled); $('ul_rate_threshold').setProperty('disabled', !isDontCountSlowTorrentsEnabled); $('torrent_inactive_timer').setProperty('disabled', !isDontCountSlowTorrentsEnabled); }; - updateMaxRatioTimeEnabled = function() { + var updateMaxRatioTimeEnabled = function() { var isMaxRatioEnabled = $('max_ratio_checkbox').getProperty('checked'); $('max_ratio_value').setProperty('disabled', !isMaxRatioEnabled); @@ -1035,34 +1035,34 @@ $('max_ratio_act').setProperty('disabled', !(isMaxRatioEnabled || isMaxSeedingTimeEnabled)); }; - updateAddTrackersEnabled = function() { + var updateAddTrackersEnabled = function() { var isAddTrackersEnabled = $('add_trackers_checkbox').getProperty('checked'); $('add_trackers_textarea').setProperty('disabled', !isAddTrackersEnabled); }; // Web UI tab - updateHttpsSettings = function() { + var updateHttpsSettings = function() { var isUseHttpsEnabled = $('use_https_checkbox').getProperty('checked'); $('ssl_key_textarea').setProperty('disabled', !isUseHttpsEnabled); $('ssl_cert_textarea').setProperty('disabled', !isUseHttpsEnabled); }; - updateBypasssAuthSettings = function() { + var updateBypasssAuthSettings = function() { var isBypassAuthSubnetWhitelistEnabled = $('bypass_auth_subnet_whitelist_checkbox').getProperty('checked'); $('bypass_auth_subnet_whitelist_textarea').setProperty('disabled', !isBypassAuthSubnetWhitelistEnabled); }; - updateAlternativeWebUISettings = function() { + var updateAlternativeWebUISettings = function() { var isUseAlternativeWebUIEnabled = $('use_alt_webui_checkbox').getProperty('checked'); $('webui_files_location_textarea').setProperty('disabled', !isUseAlternativeWebUIEnabled); }; - updateHostHeaderValidationSettings = function() { + var updateHostHeaderValidationSettings = function() { var isHostHeaderValidationEnabled = $('host_header_validation_checkbox').getProperty('checked'); $('webui_domain_textarea').setProperty('disabled', !isHostHeaderValidationEnabled); }; - updateDynDnsSettings = function() { + var updateDynDnsSettings = function() { var isDynDnsEnabled = $('use_dyndns_checkbox').getProperty('checked'); $('dyndns_select').setProperty('disabled', !isDynDnsEnabled); $('dyndns_domain_text').setProperty('disabled', !isDynDnsEnabled); @@ -1070,7 +1070,7 @@ $('dyndns_password_text').setProperty('disabled', !isDynDnsEnabled); }; - registerDynDns = function() { + var registerDynDns = function() { if ($('dyndns_select').getProperty('value').toInt() == 1) { window.open("http://www.no-ip.com/services/managed_dns/free_dynamic_dns.html", "NO-IP Registration"); } @@ -1079,21 +1079,21 @@ } }; - generateRandomPort = function() { + var generateRandomPort = function() { var min = 1024; var max = 65535; var port = Math.floor(Math.random() * (max - min + 1) + min); $('port_value').setProperty('value', port); }; - time_padding = function(val) { + var time_padding = function(val) { var ret = val.toString(); if (ret.length == 1) ret = '0' + ret; return ret; }; - loadPreferences = function() { + var loadPreferences = function() { var url = 'api/v2/app/preferences'; new Request.JSON({ url: url, @@ -1364,7 +1364,7 @@ }).send(); }; - applyPreferences = function() { + var applyPreferences = function() { var settings = new Hash(); // Validate form data // Downloads tab diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index dd186c9f7..9eef90af1 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -24,10 +24,10 @@ 'use strict'; -torrentsTable = new TorrentsTable(); -torrentPeersTable = new TorrentPeersTable(); -searchResultsTable = new SearchResultsTable(); -searchPluginsTable = new SearchPluginsTable(); +var torrentsTable = new TorrentsTable(); +var torrentPeersTable = new TorrentPeersTable(); +var searchResultsTable = new SearchResultsTable(); +var searchPluginsTable = new SearchPluginsTable(); var updatePropertiesPanel = function() {}; @@ -324,7 +324,7 @@ window.addEvent('load', function() { if (!categoryList) return; var childrens = categoryList.childNodes; - for (var i in childrens) { + for (var i = 0; i < childrens.length; ++i) { if (childrens[i].id == selected_category) childrens[i].className = "selectedFilter"; else diff --git a/src/webui/www/private/scripts/download.js b/src/webui/www/private/scripts/download.js index 643c32548..233f8f16e 100644 --- a/src/webui/www/private/scripts/download.js +++ b/src/webui/www/private/scripts/download.js @@ -26,7 +26,7 @@ var categories = {}; var defaultSavePath = ""; -getCategories = function() { +var getCategories = function() { new Request.JSON({ url: 'api/v2/torrents/categories', noCache: true, @@ -46,7 +46,7 @@ getCategories = function() { }).send(); }; -getPreferences = function() { +var getPreferences = function() { new Request.JSON({ url: 'api/v2/app/preferences', method: 'get', @@ -73,7 +73,7 @@ getPreferences = function() { }).send(); }; -changeCategorySelect = function(item) { +var changeCategorySelect = function(item) { if (item.value == "\\other") { item.nextElementSibling.hidden = false; item.nextElementSibling.value = ""; @@ -98,7 +98,7 @@ changeCategorySelect = function(item) { } }; -changeTMM = function(item) { +var changeTMM = function(item) { if (item.selectedIndex == 1) { $('savepath').disabled = true; diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js index 6643e7048..f0f7f203a 100644 --- a/src/webui/www/private/scripts/mocha-init.js +++ b/src/webui/www/private/scripts/mocha-init.js @@ -31,12 +31,43 @@ function getLocalStorageItem(name, defaultVal) { return val; } +var saveWindowSize = function() {}; +var loadWindowWidth = function() {}; +var loadWindowHeight = function() {}; +var showDownloadPage = function() {}; +var globalUploadLimitFN = function() {}; +var uploadLimitFN = function() {}; +var shareRatioFN = function() {}; +var toggleSequentialDownloadFN = function() {}; +var toggleFirstLastPiecePrioFN = function() {}; +var setSuperSeedingFN = function() {}; +var setForceStartFN = function() {}; +var globalDownloadLimitFN = function() {}; +var StatisticsLinkFN = function() {}; +var downloadLimitFN = function() {}; var deleteFN = function() {}; -var startFN = function() {}; var pauseFN = function() {}; +var startFN = function() {}; +var autoTorrentManagementFN = function() {}; +var recheckFN = function() {}; +var reannounceFN = function() {}; +var setLocationFN = function() {}; +var renameFN = function() {}; +var torrentNewCategoryFN = function() {}; +var torrentSetCategoryFN = function() {}; +var createCategoryFN = function() {}; +var editCategoryFN = function() {}; +var removeCategoryFN = function() {}; +var deleteUnusedCategoriesFN = function() {}; +var startTorrentsByCategoryFN = function() {}; +var pauseTorrentsByCategoryFN = function() {}; +var deleteTorrentsByCategoryFN = function() {}; +var copyNameFN = function() {}; +var copyMagnetLinkFN = function() {}; +var copyHashFN = function() {}; +var setPriorityFN = function() {}; -initializeWindows = function() { - +var initializeWindows = function() { saveWindowSize = function(windowId) { var size = $(windowId).getSize(); localStorage.setItem('window_' + windowId + '_width', size.x); diff --git a/src/webui/www/private/scripts/prop-files.js b/src/webui/www/private/scripts/prop-files.js index b117adf8c..089741bd0 100644 --- a/src/webui/www/private/scripts/prop-files.js +++ b/src/webui/www/private/scripts/prop-files.js @@ -352,5 +352,5 @@ var updateTorrentFilesData = function() { loadTorrentFilesData(); }; -fTable = new filesDynTable(); +var fTable = new filesDynTable(); fTable.setup($('filesTable')); diff --git a/src/webui/www/private/scripts/prop-trackers.js b/src/webui/www/private/scripts/prop-trackers.js index df6c471a0..bc00e3d22 100644 --- a/src/webui/www/private/scripts/prop-trackers.js +++ b/src/webui/www/private/scripts/prop-trackers.js @@ -232,7 +232,7 @@ var removeTrackerFN = function(element) { }).send(); }; -torrentTrackersTable = new trackersDynTable(); +var torrentTrackersTable = new trackersDynTable(); torrentTrackersTable.setup($('trackersTable'), torrentTrackersContextMenu); new ClipboardJS('#CopyTrackerUrl', { diff --git a/src/webui/www/private/scripts/prop-webseeds.js b/src/webui/www/private/scripts/prop-webseeds.js index 291574043..02c9511f0 100644 --- a/src/webui/www/private/scripts/prop-webseeds.js +++ b/src/webui/www/private/scripts/prop-webseeds.js @@ -107,5 +107,5 @@ var updateWebSeedsData = function() { loadWebSeedsData(); }; -wsTable = new webseedsDynTable(); +var wsTable = new webseedsDynTable(); wsTable.setup($('webseedsTable')); diff --git a/src/webui/www/private/uploadlimit.html b/src/webui/www/private/uploadlimit.html index 4b0b22515..50eb2bf1e 100644 --- a/src/webui/www/private/uploadlimit.html +++ b/src/webui/www/private/uploadlimit.html @@ -25,7 +25,7 @@ 'use strict'; var hashes = new URI().getData('hashes').split('|'); - setUpLimit = function() { + var setUpLimit = function() { var limit = $("uplimitUpdatevalue").value.toInt() * 1024; if (hashes[0] == "global") { new Request({