Author: damoxc
Revision: 5790
Log:
move the code that updates the buttons in the CM depending on the host
status into a single method
Diff:
Modified: trunk/deluge/ui/web/js/Deluge.ConnectionManager.js
===================================================================
--- trunk/deluge/ui/web/js/Deluge.ConnectionManager.js 2009-10-01 10:12:56 UTC
(rev 5789)
+++ trunk/deluge/ui/web/js/Deluge.ConnectionManager.js 2009-10-01 10:25:11 UTC
(rev 5790)
@@ -265,6 +265,39 @@
}, this);
},
+ /**
+ * Updates the buttons in the Connection Manager UI according to the
+ * passed in records host state.
+ * @param {Ext.data.Record} record The hosts record to update the UI
for
+ */
+ updateButtons: function(record) {
+ var button = this.buttons[1], status = record.get('status');
+
+ // Update the Connect/Disconnect button
+ if (status == _('Connected')) {
+ button.enable();
+ button.setText(_('Disconnect'));
+ } else if (status == _('Offline')) {
+ button.disable();
+ } else {
+ button.enable();
+ button.setText(_('Connect'));
+ }
+
+ // Update the Stop/Start Daemon button
+ if (status == _('Offline')) {
+ if (record.get('host') == '127.0.0.1' || record.get('host') ==
'localhost') {
+ this.stopHostButton.enable();
+ this.stopHostButton.setText(_('Start Daemon'));
+ } else {
+ this.stopHostButton.disable();
+ }
+ } else {
+ this.stopHostButton.enable();
+ this.stopHostButton.setText(_('Stop Daemon'));
+ }
+ },
+
onAdd: function(button, e) {
if (!this.addWindow) {
this.addWindow = new Ext.deluge.AddConnectionWindow();
@@ -324,22 +357,7 @@
record.set('status', host[3])
record.set('version', host[4])
record.commit();
-
- var button = this.buttons[1], status = record.get('status');
- if (this.grid.getSelectionModel().getSelected() == record) {
- var status = record.get('status');
- if (status == _('Offline')) {
- if (record.get('host') == '127.0.0.1' ||
record.get('host') == 'localhost') {
- this.stopHostButton.enable();
- this.stopHostButton.setText(_('Start Daemon'));
- } else {
- this.stopHostButton.disable();
- }
- } else {
- this.stopHostButton.enable();
- this.stopHostButton.setText(_('Stop Daemon'));
- }
- }
+ if (this.grid.getSelectionModel().getSelected() == record)
this.updateButtons(record);
},
onLogin: function() {
@@ -399,22 +417,7 @@
this.removeHostButton.disable();
this.stopHostButton.disable();
}
-
- var button = this.buttons[1], status = record.get('status');
- if (status == _('Connected')) {
- button.enable();
- button.setText(_('Disconnect'));
- } else if (status == _('Offline')) {
- button.disable();
- if (record.get('host') == '127.0.0.1' || record.get('host') ==
'localhost') {
- this.stopHostButton.setText(_('Start Daemon'));
- } else {
- this.stopHostButton.disable();
- }
- } else {
- button.enable();
- button.setText(_('Connect'));
- }
+ this.updateButtons(record);
},
onShow: function() {
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---