From 529000a6e2f02e424b4314e9e3a20f7321e2235c Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 23 May 2009 20:39:55 +0000 Subject: [PATCH] (trunk web) #2052: "warning: unresponsive script". what's new in this iteration: http://trac.transmissionbt.com/ticket/2052#comment:10 --- web/javascript/torrent.js | 93 ++++++++++++++++++---------------- web/javascript/transmission.js | 25 ++++++--- 2 files changed, 67 insertions(+), 51 deletions(-) diff --git a/web/javascript/torrent.js b/web/javascript/torrent.js index dca6d85be..38df4a311 100644 --- a/web/javascript/torrent.js +++ b/web/javascript/torrent.js @@ -36,7 +36,8 @@ Torrent.prototype = this._sizeWhenDone = data.sizeWhenDone; this._name = data.name; this._name_lc = this._name.toLowerCase( ); - + this._file_model = [ ]; + this._file_view = [ ]; // Create a new
  • element var top_e = document.createElement( 'li' ); @@ -104,23 +105,17 @@ Torrent.prototype = // insert the element this._controller._torrent_list.appendChild( top_e ); - this._files = []; this.initializeTorrentFilesInspectorGroup(); - if(data.files){ - if(data.files.length == 1) - this._fileList.className += ' single_file'; - for (var i = 0; i < data.files.length; i++) { - var file = data.files[i]; - file.index = i; - file.torrent = this; - file.priority = data.fileStats[i].priority; - file.wanted = data.fileStats[i].wanted; - var torrentFile = new TorrentFile(file); - this._files.push(torrentFile); - var e = torrentFile.domElement(); - e.className = (i % 2 ? 'even' : 'odd') + ' inspector_torrent_file_list_entry'; - this._fileList.appendChild( e ); - } + + for( var i=0; data.files!=null && i div:contains('N/A')").css('color', '#666'); this.updateVisibleFileLists(); }, + + fileListIsVisible: function() { + return this._inspector_tab_files.className.indexOf('selected') != -1; + }, updateVisibleFileLists: function() { - jQuery.each( this.getSelectedTorrents(), function() { - this.showFileList(); - } ); - jQuery.each( this.getDeselectedTorrents(), function() { - this.hideFileList(); - } ); + if( this.fileListIsVisible( ) === true ) { + jQuery.each( this.getSelectedTorrents(), function() { this.showFileList(); } ); + jQuery.each( this.getDeselectedTorrents(), function() { this.hideFileList(); } ); + } }, /* @@ -1131,10 +1136,14 @@ Transmission.prototype = updateTorrentsFileData: function( torrents ){ var tr = this; + var listIsVisible = tr.fileListIsVisible( ); jQuery.each( torrents, function() { var t = Torrent.lookup(tr._torrents, this.id); - if (t) - t.refreshFileData(this); + if (t) { + t.refreshFileModel(this); + if( listIsVisible && t.isSelected()) + t.refreshFileView(); + } } ); },