mirror of
https://github.com/transmission/transmission
synced 2025-03-03 10:15:45 +00:00
(trunk web) use "===" instead of "==" when appropriate.
This commit is contained in:
parent
651bc99ad8
commit
442d9fbea9
7 changed files with 44 additions and 45 deletions
|
@ -74,7 +74,7 @@ Array.prototype.clone = function () {
|
|||
*/
|
||||
function setInnerHTML(e, html)
|
||||
{
|
||||
if (e == undefined)
|
||||
if (!e)
|
||||
return;
|
||||
|
||||
/* innerHTML is listed as a string, but the browser seems to change it.
|
||||
|
@ -177,7 +177,7 @@ Prefs._Defaults =
|
|||
*/
|
||||
Prefs.setValue = function(key, val)
|
||||
{
|
||||
if (Prefs._Defaults[key] == undefined)
|
||||
if (!(key in Prefs._Defaults))
|
||||
console.warn("unrecognized preference key '%s'", key);
|
||||
|
||||
var days = 30;
|
||||
|
@ -196,21 +196,21 @@ Prefs.getValue = function(key, fallback)
|
|||
{
|
||||
var val;
|
||||
|
||||
if (Prefs._Defaults[key] == undefined)
|
||||
if (!(key in Prefs._Defaults))
|
||||
console.warn("unrecognized preference key '%s'", key);
|
||||
|
||||
var lines = document.cookie.split(';');
|
||||
for (var i=0, len=lines.length; !val && i<len; ++i) {
|
||||
var line = lines[i].trim();
|
||||
var delim = line.indexOf('=');
|
||||
if ((delim == key.length) && line.indexOf(key) == 0)
|
||||
if ((delim === key.length) && line.indexOf(key) === 0)
|
||||
val = line.substring(delim + 1);
|
||||
}
|
||||
|
||||
// FIXME: we support strings and booleans... add number support too?
|
||||
if (!val) val = fallback;
|
||||
else if (val == 'true') val = true;
|
||||
else if (val == 'false') val = false;
|
||||
else if (val === 'true') val = true;
|
||||
else if (val === 'false') val = false;
|
||||
return val;
|
||||
};
|
||||
|
||||
|
@ -240,15 +240,15 @@ jQuery.fn.forceNumeric = function () {
|
|||
// Numeric keypad
|
||||
key >= 96 && key <= 105 ||
|
||||
// comma, period and minus, . on keypad
|
||||
key == 190 || key == 188 || key == 109 || key == 110 ||
|
||||
key === 190 || key === 188 || key === 109 || key === 110 ||
|
||||
// Backspace and Tab and Enter
|
||||
key == 8 || key == 9 || key == 13 ||
|
||||
key === 8 || key === 9 || key === 13 ||
|
||||
// Home and End
|
||||
key == 35 || key == 36 ||
|
||||
key === 35 || key === 36 ||
|
||||
// left and right arrows
|
||||
key == 37 || key == 39 ||
|
||||
key === 37 || key === 39 ||
|
||||
// Del and Ins
|
||||
key == 46 || key == 45;
|
||||
key === 46 || key === 45;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ Dialog.prototype = {
|
|||
$('.dialog_container').hide();
|
||||
setInnerHTML(this._heading[0], dialog_heading);
|
||||
setInnerHTML(this._message[0], dialog_message);
|
||||
setInnerHTML(this._cancel_button[0], (cancel_button_label == null) ? 'Cancel' : cancel_button_label);
|
||||
setInnerHTML(this._cancel_button[0], cancel_button_label || 'Cancel');
|
||||
setInnerHTML(this._confirm_button[0], confirm_button_label);
|
||||
this._confirm_button.show();
|
||||
this._callback_function = callback_function;
|
||||
|
|
|
@ -69,12 +69,11 @@ Transmission.fmt = (function()
|
|||
* Format a ratio to a string
|
||||
*/
|
||||
ratioString: function(x) {
|
||||
if (x == -1)
|
||||
if (x === -1)
|
||||
return "None";
|
||||
else if (x == -2)
|
||||
if (x === -2)
|
||||
return '∞';
|
||||
else
|
||||
return this.percentString(x);
|
||||
return this.percentString(x);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -192,15 +191,15 @@ Transmission.fmt = (function()
|
|||
var minutes = Math.floor((seconds % 3600) / 60);
|
||||
var seconds = Math.floor((seconds % 3600) % 60);
|
||||
|
||||
if (days > 0 && hours == 0)
|
||||
if (days > 0 && hours === 0)
|
||||
result = [ days, 'days' ];
|
||||
else if (days > 0 && hours > 0)
|
||||
result = [ days, 'days', hours, 'hr' ];
|
||||
else if (hours > 0 && minutes == 0)
|
||||
else if (hours > 0 && minutes === 0)
|
||||
result = [ hours, 'hr' ];
|
||||
else if (hours > 0 && minutes > 0)
|
||||
result = [ hours,'hr', minutes, 'min' ];
|
||||
else if (minutes > 0 && seconds == 0)
|
||||
else if (minutes > 0 && seconds === 0)
|
||||
result = [ minutes, 'min' ];
|
||||
else if (minutes > 0 && seconds > 0)
|
||||
result = [ minutes, 'min', seconds, 'seconds' ];
|
||||
|
@ -221,15 +220,15 @@ Transmission.fmt = (function()
|
|||
var date = "";
|
||||
var time = "";
|
||||
|
||||
var sameYear = now.getFullYear() == myDate.getFullYear();
|
||||
var sameMonth = now.getMonth() == myDate.getMonth();
|
||||
var sameYear = now.getFullYear() === myDate.getFullYear();
|
||||
var sameMonth = now.getMonth() === myDate.getMonth();
|
||||
|
||||
var dateDiff = now.getDate() - myDate.getDate();
|
||||
if (sameYear && sameMonth && Math.abs(dateDiff) <= 1){
|
||||
if (dateDiff == 0){
|
||||
if (dateDiff === 0){
|
||||
date = "Today";
|
||||
}
|
||||
else if (dateDiff == 1){
|
||||
else if (dateDiff === 1){
|
||||
date = "Yesterday";
|
||||
}
|
||||
else{
|
||||
|
@ -246,7 +245,7 @@ Transmission.fmt = (function()
|
|||
hours = hours - 12;
|
||||
period = "PM";
|
||||
}
|
||||
if (hours == 0){
|
||||
if (hours === 0){
|
||||
hours = 12;
|
||||
}
|
||||
if (hours < 10){
|
||||
|
@ -293,7 +292,7 @@ Transmission.fmt = (function()
|
|||
case "T": explanation = "Peer is connected via uTP"; break;
|
||||
}
|
||||
|
||||
if( explanation == null ) {
|
||||
if (!explanation) {
|
||||
formattedFlags.push(flag);
|
||||
} else {
|
||||
formattedFlags.push("<span title=\"" + flag + ': ' + explanation + "\">" + flag + "</span>");
|
||||
|
|
|
@ -86,7 +86,7 @@ function Inspector(controller) {
|
|||
accumulateString = function (oldVal, newVal) {
|
||||
if (!oldVal || !oldVal.length)
|
||||
return newVal;
|
||||
if (oldVal == newVal)
|
||||
if (oldVal === newVal)
|
||||
return newVal;
|
||||
return 'Mixed';
|
||||
},
|
||||
|
@ -301,7 +301,7 @@ function Inspector(controller) {
|
|||
'<th class="clientCol">Client</th>',
|
||||
'</tr>');
|
||||
for (i=0; peer=peers[i]; ++i) {
|
||||
parity = ((i+1) % 2 == 0 ? 'even' : 'odd');
|
||||
parity = (i%2) ? 'odd' : 'even';
|
||||
html.push('<tr class="inspector_peer_entry ', parity, '">',
|
||||
'<td>', (peer.isEncrypted ? '<img src="images/graphics/lock_icon.png" alt="Encrypted"/>' : ''), '</td>',
|
||||
'<td>', (peer.rateToPeer ? fmt.speedBps(peer.rateToPeer) : ''), '</td>',
|
||||
|
@ -423,7 +423,7 @@ function Inspector(controller) {
|
|||
lastAnnounceStatusHash = lastAnnounceStatus(tracker);
|
||||
announceState = getAnnounceState(tracker);
|
||||
lastScrapeStatusHash = lastScrapeStatus(tracker);
|
||||
parity = ((j+1) % 2 == 0 ? 'even' : 'odd');
|
||||
parity = (j%2) ? 'odd' : 'even';
|
||||
html.push('<li class="inspector_tracker_entry ', parity, '"><div class="tracker_host" title="', tracker.announce, '">',
|
||||
tracker.host, '</div>',
|
||||
'<div class="tracker_activity">',
|
||||
|
|
|
@ -69,7 +69,7 @@ TransmissionRemote.prototype =
|
|||
remote = this;
|
||||
|
||||
// set the Transmission-Session-Id on a 409
|
||||
if (request.status == 409 && (token = request.getResponseHeader('X-Transmission-Session-Id'))){
|
||||
if (request.status === 409 && (token = request.getResponseHeader('X-Transmission-Session-Id'))){
|
||||
remote._token = token;
|
||||
$.ajax(ajaxObject);
|
||||
return;
|
||||
|
|
|
@ -28,17 +28,17 @@ TorrentRendererHelper.getProgressInfo = function(controller, t)
|
|||
else
|
||||
pct = 100;
|
||||
|
||||
if (s == Torrent._StatusStopped)
|
||||
if (s === Torrent._StatusStopped)
|
||||
extra = 'paused';
|
||||
else if (s == Torrent._StatusDownloadWait)
|
||||
else if (s === Torrent._StatusDownloadWait)
|
||||
extra = 'leeching queued';
|
||||
else if (t.needsMetaData())
|
||||
extra = 'magnet';
|
||||
else if (s === Torrent._StatusDownload)
|
||||
extra = 'leeching';
|
||||
else if (s == Torrent._StatusSeedWait)
|
||||
else if (s === Torrent._StatusSeedWait)
|
||||
extra = 'seeding queued';
|
||||
else if (s == Torrent._StatusSeed)
|
||||
else if (s === Torrent._StatusSeed)
|
||||
extra = 'seeding';
|
||||
else
|
||||
extra = '';
|
||||
|
@ -198,7 +198,7 @@ TorrentRendererFull.prototype =
|
|||
is_done = t.isDone() || t.isSeeding();
|
||||
|
||||
if (is_done) {
|
||||
if (totalSize == sizeWhenDone) // seed: '698.05 MiB'
|
||||
if (totalSize === sizeWhenDone) // seed: '698.05 MiB'
|
||||
c = [ Transmission.fmt.size(totalSize) ];
|
||||
else // partial seed: '127.21 MiB of 698.05 MiB (18.2%)'
|
||||
c = [ Transmission.fmt.size(sizeWhenDone),
|
||||
|
|
|
@ -205,7 +205,7 @@ Transmission.prototype =
|
|||
search_box.addClass('blur');
|
||||
search_box[0].value = 'Filter';
|
||||
search_box.bind('blur', function() {
|
||||
if (this.value == '') {
|
||||
if (this.value === '') {
|
||||
$(this).addClass('blur');
|
||||
this.value = 'Filter';
|
||||
tr.setFilterText(null);
|
||||
|
@ -287,7 +287,7 @@ Transmission.prototype =
|
|||
mins = ((i % 4) * 15);
|
||||
|
||||
value = (i * 15);
|
||||
content = hour + ":" + (mins == 0 ? "00" : mins);
|
||||
content = hour + ":" + (mins || '00');
|
||||
start.options[i] = new Option(content, value);
|
||||
end.options[i] = new Option(content, value);
|
||||
}
|
||||
|
@ -769,7 +769,7 @@ Transmission.prototype =
|
|||
$('input#limit_upload').prop('checked', up_limited);
|
||||
$('input#upload_rate').val( up_limit_k);
|
||||
$('input#refresh_rate').val( p[Prefs._RefreshRate]);
|
||||
$('div.encryption input').val( p[RPC._Encryption] == RPC._EncryptionRequired);
|
||||
$('div.encryption input').val( p[RPC._Encryption] === RPC._EncryptionRequired);
|
||||
$('input#turtle_download_rate').val( turtle_dn_limit_k);
|
||||
$('input#turtle_upload_rate').val( turtle_up_limit_k);
|
||||
$('input#turtle_schedule').prop('checked', p[RPC._TurtleTimeEnabled]);
|
||||
|
@ -880,20 +880,20 @@ Transmission.prototype =
|
|||
|
||||
// Display the preferences dialog
|
||||
case 'footer_super_menu':
|
||||
if ($element[0].id == 'preferences') {
|
||||
if ($element[0].id === 'preferences') {
|
||||
$('div#prefs_container div#pref_error').hide();
|
||||
$('div#prefs_container h2.dialog_heading').show();
|
||||
tr.showPrefsDialog();
|
||||
}
|
||||
else if ($element[0].id == 'statistics') {
|
||||
else if ($element[0].id === 'statistics') {
|
||||
$('div#stats_container div#stats_error').hide();
|
||||
$('div#stats_container h2.dialog_heading').show();
|
||||
tr.showStatsDialog();
|
||||
}
|
||||
else if ($element[0].id == 'homepage') {
|
||||
else if ($element[0].id === 'homepage') {
|
||||
window.open('http://www.transmissionbt.com/');
|
||||
}
|
||||
else if ($element[0].id == 'tipjar') {
|
||||
else if ($element[0].id === 'tipjar') {
|
||||
window.open('http://www.transmissionbt.com/donate.php');
|
||||
}
|
||||
break;
|
||||
|
@ -1060,7 +1060,7 @@ Transmission.prototype =
|
|||
// 'Apple' button emulation on PC :
|
||||
// Need settable meta-key and ctrl-key variables for mac emulation
|
||||
var meta_key = ev.metaKey;
|
||||
if (ev.ctrlKey && navigator.appVersion.toLowerCase().indexOf("mac") == -1)
|
||||
if (ev.ctrlKey && navigator.appVersion.toLowerCase().indexOf("mac") === -1)
|
||||
meta_key = true;
|
||||
|
||||
// Shift-Click - selects a range from the last-clicked row to this one
|
||||
|
@ -1171,7 +1171,7 @@ Transmission.prototype =
|
|||
|
||||
promptToRemoveTorrents:function(torrents)
|
||||
{
|
||||
if (torrents.length == 1)
|
||||
if (torrents.length === 1)
|
||||
{
|
||||
var torrent = torrents[0];
|
||||
var header = 'Remove ' + torrent.getName() + '?';
|
||||
|
@ -1188,7 +1188,7 @@ Transmission.prototype =
|
|||
|
||||
promptToRemoveTorrentsAndData:function(torrents)
|
||||
{
|
||||
if (torrents.length == 1)
|
||||
if (torrents.length === 1)
|
||||
{
|
||||
var torrent = torrents[0],
|
||||
header = 'Remove ' + torrent.getName() + ' and delete data?',
|
||||
|
@ -1416,7 +1416,7 @@ Transmission.prototype =
|
|||
{
|
||||
var o, tmp, text, torrent_count,
|
||||
state = this[Prefs._FilterMode],
|
||||
state_all = state == Prefs._FilterAll,
|
||||
state_all = state === Prefs._FilterAll,
|
||||
state_string = this.getStateString(state),
|
||||
tracker = this.filterTracker,
|
||||
tracker_all = !tracker,
|
||||
|
|
Loading…
Reference in a new issue