Author: damoxc

Revision: 6119

Log:
        fix the formatting and change it so the events manager is started on 
the login event

Diff:
Modified: trunk/deluge/ui/web/js/Deluge.Events.js
===================================================================
--- trunk/deluge/ui/web/js/Deluge.Events.js     2010-01-23 15:37:04 UTC (rev 
6118)
+++ trunk/deluge/ui/web/js/Deluge.Events.js     2010-01-23 15:38:07 UTC (rev 
6119)
@@ -41,52 +41,59 @@
 (function() {
     Events = Ext.extend(Ext.util.Observable, {
         constructor: function() {
-           this.toRegister = [];
+                       this.toRegister = [];
+                       this.on('login', this.onLogin, this);
             Events.superclass.constructor.call(this);
         },
         
         addListener: function(eventName, fn, scope, o) {
             this.addEvents(eventName);
-           if (/[A-Z]/.test(eventName.substring(0, 1))) {
-               if (!Deluge.Client) {
-                   this.toRegister.push(eventName);
-               } else {
-                   Deluge.Client.web.register_event_listener(eventName);
-               }
-           }
+                       if (/[A-Z]/.test(eventName.substring(0, 1))) {
+                               if (!Deluge.Client) {
+                                       this.toRegister.push(eventName);
+                               } else {
+                                       
Deluge.Client.web.register_event_listener(eventName);
+                               }
+                       }
             Events.superclass.addListener.call(this, eventName, fn, scope, o);
         },
        
-       poll: function() {
-           Deluge.Client.web.get_events({
-               success: this.onPollSuccess,
-               scope: this
-           });
-       },
+               poll: function() {
+                       Deluge.Client.web.get_events({
+                               success: this.onPollSuccess,
+                               scope: this
+                       });
+               },
        
-       start: function() {
-           Ext.each(this.toRegister, function(eventName) {
-               Deluge.Client.web.register_event_listener(eventName);
-           });
-           this.poll = this.poll.bind(this);
-           this.running = setInterval(this.poll, 2000);
-           this.poll();
-       },
+               start: function() {
+                       Ext.each(this.toRegister, function(eventName) {
+                               
Deluge.Client.web.register_event_listener(eventName);
+                       });
+                       this.poll = this.poll.bind(this);
+                       this.running = setInterval(this.poll, 2000);
+                       this.poll();
+               },
        
-       stop: function() {
-           if (this.running) {
-               clearInterval(this.running); 
-           }
-       },
+               stop: function() {
+                       if (this.running) {
+                               clearInterval(this.running); 
+                       }
+               },
+
+               onLogin: function() {
+                       this.start();
+                       this.on('PluginEnabledEvent', this.onPluginEnabled, 
this);
+                       this.on('PluginDisabledEvent', this.onPluginDisabled, 
this);
+               },
        
-       onPollSuccess: function(events) {
-           if (!events) return;
-           Ext.each(events, function(event) {
-               var name = event[0], args = event[1];
-               args.splice(0, 0, name);
-               this.fireEvent.apply(this, args);
-           }, this);
-       }
+               onPollSuccess: function(events) {
+                       if (!events) return;
+                       Ext.each(events, function(event) {
+                               var name = event[0], args = event[1];
+                               args.splice(0, 0, name);
+                               this.fireEvent.apply(this, args);
+                       }, this);
+               }
     });
     Events.prototype.on = Events.prototype.addListener
     Events.prototype.fire = Events.prototype.fireEvent


-- 
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.

Reply via email to