From 066d261f8c46d49e36a33389e374b6eab5ac038c Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Thu, 15 Jul 2010 15:16:10 +0000 Subject: [PATCH] (web) #2908:Retrieve info for selected torrents --- web/javascript/transmission.js | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js index 2da5c7a95..ba7e55883 100644 --- a/web/javascript/transmission.js +++ b/web/javascript/transmission.js @@ -522,6 +522,7 @@ Transmission.prototype = { this.updateButtonStates(); this.updateInspector(); + this.updateSelectedData(); }, /*-------------------------------------------- @@ -829,6 +830,38 @@ Transmission.prototype = } }, + /* + * Turn the periodic ajax torrents refresh on & off for the selected torrents + */ + periodicTorrentUpdate: function( ids ) { + var tr = this; + if( ids ) { + var curIds = this._extra_data_ids; + if( curIds == null ) + curIds = [ ]; + if( ids.length == curIds.length ) { + var duplicate = true; + for(var i = 0; i < ids.length; i++ ) { + if( ids[i] != curIds[i] ) { + duplicate = false; + break; + } + } + if( duplicate ) return; + } + tr.refreshTorrents(ids); + clearInterval(this._metadata_refresh); + // sanity check + if( !this[Prefs._RefreshRate] ) this[Prefs._RefreshRate] = 5; + this._metadata_refresh = setInterval(function(){ tr.refreshTorrents(ids); }, this[Prefs._RefreshRate] * 1000 ); + this._extra_data_ids = ids; + } else { + clearInterval(this._metadata_refresh); + this._metadata_refresh = null; + this._extra_data_ids = null; + } + }, + /* * Turn the periodic ajax session refresh on & off */ @@ -876,6 +909,15 @@ Transmission.prototype = this.remote.savePrefs( args ); }, + updateSelectedData: function() + { + var ids = jQuery.map(this.getSelectedTorrents( ), function(t) { return t.id(); } ); + if( ids.length > 0 ) + this.periodicTorrentUpdate( ids ); + else + this.periodicTorrentUpdate( false ); + }, + updateTurtleButton: function() { var w = $('#turtle_button'); var t;