From 28bbd0cc621c74f0854736225dbd374ee34a741b Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Sat, 21 Feb 2009 04:04:05 +0000 Subject: [PATCH] clear all the tabs (that have data) when the client disconnects --- deluge/ui/web/js/deluge-details.js | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/deluge/ui/web/js/deluge-details.js b/deluge/ui/web/js/deluge-details.js index 2cbe72d79..cd26137e9 100644 --- a/deluge/ui/web/js/deluge-details.js +++ b/deluge/ui/web/js/deluge-details.js @@ -54,6 +54,12 @@ Deluge.ProgressBar = Ext.extend(Ext.ProgressBar, { Ext.reg('deluge-progress', Deluge.ProgressBar); Deluge.Details = { + clear: function() { + this.Panel.items.each(function(item) { + if (item.clear) item.clear(); + }); + }, + update: function(tab) { var torrent = Deluge.Torrents.getSelected(); if (!torrent) return; @@ -66,6 +72,7 @@ Deluge.Details = { onRender: function(panel) { Deluge.Torrents.Grid.on('rowclick', this.onTorrentsClick.bindWithEvent(this)); + Deluge.Events.on('disconnect', this.clear.bind(this)); }, onTabChange: function(panel, tab) { @@ -92,6 +99,7 @@ Deluge.Details.Status = { listeners: {'render': Deluge.Details.Status.onStatusRender} }); this.panel.update = this.update.bind(this); + this.panel.clear = this.clear.bind(this); }, onStatusRender: function(panel) { @@ -142,6 +150,14 @@ Deluge.Details.Status = { Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Status, { onSuccess: this.onRequestComplete.bind(this) }); + }, + + clear: function() { + if (!this.fields) return; + this.progressBar.updateProgress(0, ' '); + this.fields.each(function(value, key) { + value.set('text', ''); + }, this); } } @@ -154,6 +170,7 @@ Deluge.Details.Details = { }); this.doUpdate = false; this.panel.update = this.update.bind(this); + this.panel.clear = this.clear.bind(this); }, onLoaded: function() { @@ -192,12 +209,25 @@ Deluge.Details.Details = { Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Details, { onSuccess: this.onRequestComplete.bindWithEvent(this, torrentId) }); + }, + + clear: function() { + if (!this.fields) return; + this.fields.each(function(value, key) { + value.set('text', ''); + }, this); } } Deluge.Details.Files = { onRender: function(panel) { this.panel = panel; + this.panel.clear = this.clear.bind(this); + this.panel.update = this.update.bind(this); + }, + + clear: function() { + }, update: function(torrentId) { @@ -209,6 +239,7 @@ Deluge.Details.Peers = { onRender: function(panel) { this.panel = panel; this.panel.update = this.update.bind(this); + this.panel.clear = this.clear.bind(this); }, onRequestComplete: function(torrent) { @@ -219,6 +250,10 @@ Deluge.Details.Peers = { this.Store.loadData(peers); }, + clear: function() { + this.Store.loadData([]); + }, + update: function(torrentId) { Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Peers, { onSuccess: this.onRequestComplete.bindWithEvent(this, torrentId)