From 9cb9fd56d9a9f3ab18fe3107292eb6ab30b779e0 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sat, 27 Aug 2011 00:22:56 +0000 Subject: [PATCH] (trunk web) slightly faster Transmission.refilter(). Modify Transmission.refreshFilterPopup(), Torrent.getCollatedName(), and Torrent.getCollatedTrackers() for clarity. --- web/javascript/torrent.js | 14 ++++---------- web/javascript/transmission.js | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/web/javascript/torrent.js b/web/javascript/torrent.js index a7f8f7aa3..a9cc38075 100644 --- a/web/javascript/torrent.js +++ b/web/javascript/torrent.js @@ -282,20 +282,14 @@ Torrent.prototype = }, getCollatedName: function() { var f = this.fields; - if (!f.collatedName) { - var name = this.fields.name; - if (name) - f.collatedName = name.toLowerCase(); - } + if (!f.collatedName && f.name) + f.collatedName = f.name.toLowerCase(); return f.collatedName || ''; }, getCollatedTrackers: function() { var f = this.fields; - if (!f.collatedTrackers) { - var trackers = this.getTrackers(); - if (trackers) - f.collatedTrackers = this.collateTrackers(trackers); - } + if (!f.collatedTrackers && f.trackers) + f.collatedTrackers = this.collateTrackers(f.trackers); return f.collatedTrackers || ''; }, diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js index 03fca798d..6b717949e 100644 --- a/web/javascript/transmission.js +++ b/web/javascript/transmission.js @@ -1104,6 +1104,8 @@ Transmission.prototype = var ids = this.getSelectedTorrentIds(); if (ids && ids.length) { var fields = ['id'].concat(Torrent.Fields.StatsExtra); + if (full) + fields = fields.concat(Torrent.Fields.InfoExtra); this.remote.updateTorrents(ids, fields, this.updateFromTorrentGet, this); } } @@ -1956,11 +1958,12 @@ Transmission.prototype = delete this.refilterTimer; // make a filtered, sorted array of our torrents - var keep = []; - var all_torrents = this.getAllTorrents(); - for (var i=0, t; t=all_torrents[i]; ++i) - if (t.test(this[Prefs._FilterMode], this._current_search, this.filterTracker)) - keep.push(t); + var filter_mode = this[Prefs._FilterMode]; + var filter_text = this._current_search; + var filter_tracker = this.filterTracker; + var keep = $.grep(this.getAllTorrents(), function(t) { + return t.test(filter_mode, filter_text, filter_tracker); + }); Torrent.sortTorrents(keep, this[Prefs._SortMethod], this[Prefs._SortDirection]); // maybe rebuild the rows @@ -1973,10 +1976,11 @@ Transmission.prototype = var tr = this; var rows = [ ]; var fragment = document.createDocumentFragment(); + var renderer = this.torrentRenderer; for (var i=0, tor; tor=keep[i]; ++i) { var is_selected = old_sel.indexOf(tor) !== -1; - var row = new TorrentRow(this.torrentRenderer, this, tor, is_selected); + var row = new TorrentRow(renderer, this, tor, is_selected); row.setEven((i+1) % 2 == 0); if (is_selected) new_sel_count++; @@ -1985,8 +1989,8 @@ Transmission.prototype = if (b) $(b).click({r:row}, function(ev) {tr.onToggleRunningClicked(ev);}); } - $(row.getElement()).click({r: row}, function(ev) {tr.onRowClicked(ev,ev.data.r);}); - $(row.getElement()).dblclick(function() { tr.toggleInspector();}); + $(row.getElement()).click({r: row}, function(ev) {tr.onRowClicked(ev,ev.data.r);}) + .dblclick(function() {tr.toggleInspector();}); fragment.appendChild(row.getElement()); rows.push(row); } @@ -2058,10 +2062,7 @@ Transmission.prototype = ***/ var trackers = this.getTrackers(); - var names = []; - for (var name in trackers) - names.push(name); - names.sort(); + var names = Object.keys(trackers).sort(); var fragment = document.createDocumentFragment(); var div = document.createElement('div'); -- 2.40.0