Changeset 12747
- Timestamp:
- Aug 26, 2011, 12:43:35 AM (12 years ago)
- Location:
- trunk/web/javascript
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/javascript/torrent-row.js
r12736 r12747 370 370 return this._torrent; 371 371 }, 372 getTorrentId: function() { 373 return this.getTorrent().getId(); 374 }, 372 375 isEven: function() { 373 376 return this.getElement().className.indexOf('even') != -1; -
trunk/web/javascript/transmission.js
r12745 r12747 410 410 for (var i=0, row; row=this._rows[i]; ++i) 411 411 if (row.isSelected()) 412 s.push(row.getTorrent ().getId());412 s.push(row.getTorrentId()); 413 413 return s; 414 414 }, … … 445 445 indexOfLastTorrent: function() { 446 446 for (var i=0, r; r=this._rows[i]; ++i) 447 if (r.getTorrent ().getId() === this._last_torrent_clicked)447 if (r.getTorrentId() === this._last_torrent_clicked) 448 448 return i; 449 449 return -1; … … 544 544 this.setSelectedRow(r); 545 545 } 546 this._last_torrent_clicked = r.getTorrent ().getId();546 this._last_torrent_clicked = r.getTorrentId(); 547 547 this.scrollToRow(r); 548 548 } … … 1636 1636 } 1637 1637 1638 this._last_torrent_clicked = row.getTorrent ().getId();1638 this._last_torrent_clicked = row.getTorrentId(); 1639 1639 }, 1640 1640 … … 1979 1979 }, 1980 1980 1981 matchesTorrentList: function(torrents) 1982 { 1983 if (!torrents || !this._rows) 1984 return false; 1985 if (torrents.length !== this._rows.length) 1986 return false; 1987 1988 for (var i=0, tor; tor=torrents[i]; ++i) 1989 if (tor.getId() !== this._rows[i].getTorrentId()) 1990 return false; 1991 1992 return true; 1993 }, 1994 1981 1995 refilter: function() 1982 1996 { … … 1984 1998 delete this.refilterTimer; 1985 1999 1986 // decide which torrents to show2000 // make a filtered, sorted array of our torrents 1987 2001 var keep = []; 1988 2002 var all_torrents = this.getAllTorrents(); … … 1990 2004 if (t.test(this[Prefs._FilterMode], this._current_search, this.filterTracker)) 1991 2005 keep.push(t); 1992 1993 // sort the torrents we're going to show 1994 Torrent.sortTorrents(keep, this[Prefs._SortMethod], 1995 this[Prefs._SortDirection]); 1996 1997 // make a temporary backup of the selection 1998 var sel = this.getSelectedTorrents(); 1999 var new_sel_count = 0; 2000 2001 // make the new rows 2002 var tr = this; 2003 var rows = [ ]; 2004 var fragment = document.createDocumentFragment(); 2005 for (var i=0, tor; tor=keep[i]; ++i) 2006 Torrent.sortTorrents(keep, this[Prefs._SortMethod], this[Prefs._SortDirection]); 2007 2008 // maybe rebuild the rows 2009 if (!this.matchesTorrentList(keep)) 2006 2010 { 2007 var is_selected = sel.indexOf(tor) !== -1; 2008 var row = new TorrentRow(this.torrentRenderer, this, tor, is_selected); 2009 row.setEven((i+1) % 2 == 0); 2010 if (is_selected) 2011 new_sel_count++; 2012 if (!iPhone) { 2013 var b = row.getToggleRunningButton(); 2014 if (b) 2015 $(b).click({r:row}, function(ev) {tr.onToggleRunningClicked(ev);}); 2011 var old_sel = this.getSelectedTorrents(); 2012 var new_sel_count = 0; 2013 2014 // make the new rows 2015 var tr = this; 2016 var rows = [ ]; 2017 var fragment = document.createDocumentFragment(); 2018 for (var i=0, tor; tor=keep[i]; ++i) 2019 { 2020 var is_selected = old_sel.indexOf(tor) !== -1; 2021 var row = new TorrentRow(this.torrentRenderer, this, tor, is_selected); 2022 row.setEven((i+1) % 2 == 0); 2023 if (is_selected) 2024 new_sel_count++; 2025 if (!iPhone) { 2026 var b = row.getToggleRunningButton(); 2027 if (b) 2028 $(b).click({r:row}, function(ev) {tr.onToggleRunningClicked(ev);}); 2029 } 2030 $(row.getElement()).click({r: row}, function(ev) {tr.onRowClicked(ev,ev.data.r);}); 2031 $(row.getElement()).dblclick(function() { tr.toggleInspector();}); 2032 fragment.appendChild(row.getElement()); 2033 rows.push(row); 2016 2034 } 2017 $(row.getElement()).click({r: row}, function(ev) {tr.onRowClicked(ev,ev.data.r);}); 2018 $(row.getElement()).dblclick(function() { tr.toggleInspector();}); 2019 fragment.appendChild(row.getElement()); 2020 rows.push(row); 2021 } 2022 $('ul.torrent_list').empty(); 2023 delete this._rows; 2024 this._rows = rows; 2025 this._torrent_list.appendChild(fragment); 2035 $('ul.torrent_list').empty(); 2036 delete this._rows; 2037 this._rows = rows; 2038 this._torrent_list.appendChild(fragment); 2039 2040 if (old_sel.length !== new_sel_count) 2041 this.selectionChanged(); 2042 } 2026 2043 2027 2044 // sync gui 2028 2045 this.updateStatusbar(); 2029 if (sel.length !== new_sel_count)2030 this.selectionChanged();2031 2046 this.refreshFilterButton(); 2032 2047 },
Note: See TracChangeset
for help on using the changeset viewer.