From: Jordan Lee Date: Wed, 14 Sep 2011 15:32:12 +0000 (+0000) Subject: (trunk web) minor code cleanup: formatting consistency, move var declarations to... X-Git-Tag: 2.40b1~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ddbfb07514b46fb48075479a1c2f6be37501a374;p=transmission (trunk web) minor code cleanup: formatting consistency, move var declarations to the beginning of functions, fit better in 80 columns. --- diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js index 4c9fec8be..a1032a264 100644 --- a/web/javascript/transmission.js +++ b/web/javascript/transmission.js @@ -30,9 +30,9 @@ Transmission.prototype = // Initialize the implementation fields this.filterText = ''; - this._torrents = { }; - this._rows = [ ]; - this.dirtyTorrents = { }; + this._torrents = {}; + this._rows = []; + this.dirtyTorrents = {}; // Initialize the clutch preferences Prefs.getClutchPrefs(this); @@ -247,9 +247,6 @@ Transmission.prototype = }); }, - /* - * Create the footer settings menu - */ createSettingsMenu: function() { $('#settings_menu').transMenu({ selected_char: '✔', @@ -276,6 +273,11 @@ Transmission.prototype = return torrents; }, + getTorrentIds: function(torrents) + { + return $.map(torrents.slice(0), function(t) {return t.getId();}); + }, + scrollToRow: function(row) { if (isMobileDevice) // FIXME: why? @@ -323,9 +325,7 @@ Transmission.prototype = }, getSelectedTorrentIds: function() { - return $.map(this.getSelectedRows(),function(r) { - return r.getTorrentId(); - }); + return this.getTorrentIds(this.getSelectedTorrents()); }, setSelectedRow: function(row) { @@ -360,7 +360,7 @@ Transmission.prototype = return -1; }, - /* Select a range from this torrent to the last clicked torrent */ + // Select a range from this row to the last clicked torrent selectRange: function(row) { var last = this.indexOfLastTorrent(); @@ -395,8 +395,11 @@ Transmission.prototype = callSelectionChangedSoon: function() { if (!this.selectionChangedTimer) - this.selectionChangedTimer = - setTimeout($.proxy(this.selectionChanged,this),200); + { + var callback = $.proxy(this.selectionChanged,this), + msec = 200; + this.selectionChangedTimer = setTimeout(callback, msec); + } }, /*-------------------------------------------- @@ -466,8 +469,7 @@ Transmission.prototype = return !handled; }, - keyUp: function(ev) - { + keyUp: function(ev) { if (ev.keyCode === 16) // shift key pressed delete this._shift_index; }, @@ -534,31 +536,27 @@ Transmission.prototype = return true; }, - drop: function(ev) { - if (!ev.dataTransfer || !ev.dataTransfer.types) { + drop: function(ev) + { + var i, uri, uris=null, + types = ["text/uri-list", "text/plain"]; + paused = this.shouldAddedTorrentsStart(); + + if (!ev.dataTransfer || !ev.dataTransfer.types) return true; - } - ev.preventDefault(); - var uris = null; - var types = ["text/uri-list", "text/plain"]; - for (var i = 0; i < types.length; ++i) { - if (ev.dataTransfer.types.contains(types[i])) { + + for (i=0; !uris && i' @@ -1567,17 +1571,16 @@ Transmission.prototype = setFilterTracker: function(domain) { - this.filterTracker = domain; - // update which tracker is selected in the popup - var key = domain ? this.getReadableDomain(domain) : 'all'; - var id = '#show-tracker-' + key; + var key = domain ? this.getReadableDomain(domain) : 'all', + id = '#show-tracker-' + key; $(id).addClass('selected').siblings().removeClass('selected'); + this.filterTracker = domain; this.refilter(true); }, - /* example: "tracker.ubuntu.com" returns "ubuntu.com" */ + // example: "tracker.ubuntu.com" returns "ubuntu.com" getDomainName: function(host) { var dot = host.indexOf('.'); @@ -1586,7 +1589,7 @@ Transmission.prototype = return host; }, - /* example: "ubuntu.com" returns "Ubuntu" */ + // example: "ubuntu.com" returns "Ubuntu" getReadableDomain: function(name) { if (name.length) @@ -1610,7 +1613,9 @@ Transmission.prototype = var domain = this.getDomainName(uri.host); var name = this.getReadableDomain(domain); if (!(name in ret)) - ret[name] = { 'uri': uri, 'domain': domain, 'count': 0 }; + ret[name] = { 'uri': uri, + 'domain': domain, + 'count': 0 }; if (names.indexOf(name) === -1) names.push(name); }