From 7840d85a24894d456bffb09741f8ea52c61c31c9 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 14 Nov 2009 14:57:47 +0000 Subject: [PATCH] (trunk web) #2157: web ui should support turtle mode --- web/javascript/common.js | 1 + web/javascript/transmission.js | 24 +++++++++++++++++++++++- web/javascript/transmission.remote.js | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/web/javascript/common.js b/web/javascript/common.js index 82bc7b5fd..57876ec61 100644 --- a/web/javascript/common.js +++ b/web/javascript/common.js @@ -286,6 +286,7 @@ Prefs.prototype = { }; Prefs._AutoStart = 'auto-start-torrents'; Prefs._RefreshRate = 'refresh_rate'; +Prefs._SessionRefreshRate = 'session_refresh_rate'; Prefs._ShowFilter = 'show_filter'; diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js index 74c4f80e4..3a1a25590 100644 --- a/web/javascript/transmission.js +++ b/web/javascript/transmission.js @@ -121,6 +121,7 @@ Transmission.prototype = this.initializeAllTorrents(); this.togglePeriodicRefresh( true ); + this.togglePeriodicSessionRefresh( true ); }, loadDaemonPrefs: function( async ){ @@ -739,7 +740,7 @@ Transmission.prototype = }, /* - * Turn the periodic ajax-refresh on & off + * Turn the periodic ajax torrents refresh on & off */ togglePeriodicRefresh: function(state) { var tr = this; @@ -755,6 +756,25 @@ Transmission.prototype = } }, + /* + * Turn the periodic ajax session refresh on & off + */ + togglePeriodicSessionRefresh: function(state) { + var tr = this; + if (state && this._periodic_session_refresh == null) { + // sanity check + if( !this[Prefs._SessionRefreshRate] ) + this[Prefs._SessionRefreshRate] = 5; + remote = this.remote; + this._periodic_session_refresh = setInterval( + function(){ tr.loadDaemonPrefs(); }, this[Prefs._SessionRefreshRate] * 1000 + ); + } else { + clearInterval(this._periodic_session_refresh); + this._periodic_session_refresh = null; + } + }, + toggleTurtleClicked: function() { // Toggle the value this[Prefs._TurtleState] = !this[Prefs._TurtleState]; @@ -787,6 +807,7 @@ Transmission.prototype = if( Safari3 ) setTimeout("$('div#prefs_container div.dialog_window').css('top', '0px');",10); this.updateButtonStates( ); + this.togglePeriodicSessionRefresh(false); }, hidePrefsDialog: function( ) @@ -802,6 +823,7 @@ Transmission.prototype = $('#prefs_container').hide(); } this.updateButtonStates( ); + this.togglePeriodicSessionRefresh(true); }, /* diff --git a/web/javascript/transmission.remote.js b/web/javascript/transmission.remote.js index 96ebcd693..38a4cc760 100644 --- a/web/javascript/transmission.remote.js +++ b/web/javascript/transmission.remote.js @@ -73,6 +73,7 @@ TransmissionRemote.prototype = null, 'Dismiss'); remote._controller.togglePeriodicRefresh(false); + remote._controller.togglePeriodicSessionRefresh(false); }, appendSessionId: function(XHR) { -- 2.40.0