Module: deluge Branch: master Commit: 5b0f93ba7217981c3e01886128a595c3ded339b7
Author: Damien Churchill <[email protected]> Date: Mon May 3 02:14:51 2010 +0100 improve behaviour when webserver goes away --- deluge/ui/web/js/deluge-all/UI.js | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/deluge/ui/web/js/deluge-all/UI.js b/deluge/ui/web/js/deluge-all/UI.js index 15f7881..4f8efd8 100644 --- a/deluge/ui/web/js/deluge-all/UI.js +++ b/deluge/ui/web/js/deluge-all/UI.js @@ -98,10 +98,19 @@ deluge.ui = { }, this, {single: true}); this.update = this.update.createDelegate(this); + this.checkConnection = this.checkConnection.createDelegate(this); this.originalTitle = document.title; }, + checkConnection: function() { + deluge.client.web.connected({ + success: this.onConnectionSuccess, + failure: this.onConnectionError, + scope: this + }); + }, + update: function() { var filters = deluge.sidebar.getFilterStates(); deluge.client.web.update_ui(Deluge.Keys.Grid, filters, { @@ -112,6 +121,18 @@ deluge.ui = { deluge.details.update(); }, + onConnectionError: function(error) { + + }, + + onConnectionSuccess: function(result) { + deluge.statusbar.setStatus('Connection restored'); + clearInterval(this.checking); + if (!result) { + deluge.connectionManager.show(); + } + }, + onUpdateError: function(error) { if (this.errorCount == 2) { Ext.MessageBox.show({ @@ -120,6 +141,9 @@ deluge.ui = { buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.ERROR }); + deluge.events.fire('disconnect'); + deluge.statusbar.setStatus('Lost connection to webserver'); + this.checking = setInterval(this.checkConnection, 2000); } this.errorCount++; }, -- You received this message because you are subscribed to the Google Groups "deluge-commit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/deluge-commit?hl=en.
