Skip to content

Commit

Permalink
Merge pull request #9959 from Chocobo1/strict
Browse files Browse the repository at this point in the history
Use Javascript strict mode
  • Loading branch information
Chocobo1 authored Dec 20, 2018
2 parents 8ab94d7 + d0886f8 commit 25cefee
Show file tree
Hide file tree
Showing 30 changed files with 299 additions and 211 deletions.
2 changes: 2 additions & 0 deletions src/webui/www/private/addtrackers.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<script src="scripts/lib/mootools-1.2-core-yc.js"></script>
<script src="scripts/lib/mootools-1.2-more.js"></script>
<script>
'use strict';

window.addEvent('domready', function() {
var setLocationKeyboardEvents = new Keyboard({
defaultEventType: 'keydown',
Expand Down
2 changes: 2 additions & 0 deletions src/webui/www/private/confirmdeletion.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<script src="scripts/lib/mootools-1.2-core-yc.js"></script>
<script src="scripts/lib/mootools-1.2-more.js"></script>
<script>
'use strict';

var hashes = new URI().getData('hashes').split('|');
window.addEvent('domready', function() {
$('cancelBtn').focus();
Expand Down
2 changes: 2 additions & 0 deletions src/webui/www/private/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ <h2 class="vcenter">QBT_TR(Download Torrents from their URLs or Magnet links)QBT
</div>
</form>
<script>
'use strict';

var encodedUrls = new URI().getData('urls');
if (encodedUrls) {
var urls = [];
Expand Down
4 changes: 3 additions & 1 deletion src/webui/www/private/downloadlimit.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
<div class="clear"></div>
</div>
<script>
'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({
Expand Down
2 changes: 2 additions & 0 deletions src/webui/www/private/filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
</div>

<script>
'use strict';

var categoriesFilterContextMenu = new CategoriesFilterContextMenu({
targets: '.categoriesFilterContextMenuTarget',
menu: 'categoriesFilterMenu',
Expand Down
7 changes: 4 additions & 3 deletions src/webui/www/private/installsearchplugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
width: 100%;
line-height: 2em;
}

</style>

<div id="installSearchPluginContainer">
Expand All @@ -20,7 +21,7 @@ <h2>QBT_TR(Plugin path:)QBT_TR[CONTEXT=PluginSourceDlg]</h2>
<input type="text" id="newPluginPath" placeholder="QBT_TR(URL or local directory)QBT_TR[CONTEXT=PluginSourceDlg]" autocorrect="off" autocapitalize="none" />
<div style="margin-top: 10px; text-align: center;">
<button id="newPluginCancel" onclick="closeSearchWindow('installSearchPlugin');">QBT_TR(Cancel)QBT_TR[CONTEXT=PluginSourceDlg]</button>
<button id="newPluginOk" onclick="newPluginOk();">QBT_TR(Ok)QBT_TR[CONTEXT=PluginSourceDlg]</button></div>
<button id="newPluginOk" onclick="newPluginOk();">QBT_TR(Ok)QBT_TR[CONTEXT=PluginSourceDlg]</button>
</div>
</div>
</div>
Expand All @@ -32,7 +33,7 @@ <h2>QBT_TR(Plugin path:)QBT_TR[CONTEXT=PluginSourceDlg]</h2>
var installSearchPluginKeyboardEvents = new Keyboard({
defaultEventType: 'keydown',
events: {
'enter': function (e) {
'enter': function(e) {
// accept enter key as a click
new Event(e).stop();

Expand All @@ -59,7 +60,7 @@ <h2>QBT_TR(Plugin path:)QBT_TR[CONTEXT=PluginSourceDlg]</h2>
data: {
sources: path,
},
onRequest: function(){
onRequest: function() {
closeSearchWindow('installSearchPlugin');
}
}).send();
Expand Down
2 changes: 2 additions & 0 deletions src/webui/www/private/newcategory.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<script src="scripts/lib/mootools-1.2-more.js"></script>
<script src="scripts/misc.js?locale=${LANG}"></script>
<script>
'use strict';

var newCategoryKeyboardEvents = new Keyboard({
defaultEventType: 'keydown',
events: {
Expand Down
2 changes: 2 additions & 0 deletions src/webui/www/private/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
</div>

<script>
'use strict';

// Tabs
MochaUI.initializeTabs('preferencesTabs');

Expand Down
74 changes: 38 additions & 36 deletions src/webui/www/private/preferences_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<tr>
<td>
<input type="checkbox" id="temppath_checkbox" onclick="updateTempDirEnabled();" />
<label for="temppath_checkbox" >QBT_TR(Keep incomplete torrents in:)QBT_TR[CONTEXT=OptionsDialog]</label>
<label for="temppath_checkbox">QBT_TR(Keep incomplete torrents in:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="temppath_text" />
Expand All @@ -95,7 +95,7 @@
<tr>
<td>
<input type="checkbox" id="exportdir_checkbox" onclick="updateExportDirEnabled();" />
<label for="exportdir_checkbox" >QBT_TR(Copy .torrent files to:)QBT_TR[CONTEXT=OptionsDialog]</label>
<label for="exportdir_checkbox">QBT_TR(Copy .torrent files to:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="exportdir_text" />
Expand All @@ -104,7 +104,7 @@
<tr>
<td>
<input type="checkbox" id="exportdirfin_checkbox" onclick="updateExportDirFinEnabled();" />
<label for="exportdirfin_checkbox" >QBT_TR(Copy .torrent files for finished downloads to:)QBT_TR[CONTEXT=OptionsDialog]</label>
<label for="exportdirfin_checkbox">QBT_TR(Copy .torrent files for finished downloads to:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<input type="text" id="exportdirfin_text" />
Expand Down Expand Up @@ -814,15 +814,17 @@
<div style="text-align: center; margin-top: 1em;"><input type="button" value="QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" onclick="applyPreferences();" /></div>

<script>
'use strict';

// 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;

Expand All @@ -842,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]';
Expand All @@ -855,7 +857,7 @@
}
};

pushWatchFolder = function(pos, folder, sel, other) {
var pushWatchFolder = function(pos, folder, sel, other) {
var myinput = "<input id='text_watch_" + pos + "' type='text' value='" + folder + "'>";
var disableInput = (sel != "other");
var mycb = "<div class='select-watched-folder-editable'>"
Expand All @@ -875,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) {
Expand All @@ -895,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);
Expand All @@ -919,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);
Expand All @@ -977,27 +979,27 @@
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);
$('banned_IPs_textarea').setProperty('disabled', !isIPFilterEnabled);
};

// 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);
Expand All @@ -1007,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);
Expand All @@ -1016,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);

Expand All @@ -1033,42 +1035,42 @@
$('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);
$('dyndns_username_text').setProperty('disabled', !isDynDnsEnabled);
$('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");
}
Expand All @@ -1077,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,
Expand Down Expand Up @@ -1362,7 +1364,7 @@
}).send();
};

applyPreferences = function() {
var applyPreferences = function() {
var settings = new Hash();
// Validate form data
// Downloads tab
Expand Down
2 changes: 2 additions & 0 deletions src/webui/www/private/properties_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@
</div>

<script>
'use strict';

torrentPeersTable.setup('torrentPeersTableDiv', 'torrentPeersTableFixedHeaderDiv', null);
var selectedTab = $(getLocalStorageItem('selected_tab', 'PropGeneralLink'));
if (selectedTab)
Expand Down
Loading

0 comments on commit 25cefee

Please sign in to comment.