diff --git a/deluge/ui/web/js/deluge-bars.js b/deluge/ui/web/js/deluge-bars.js index e8fb4b5e4..031380ef4 100644 --- a/deluge/ui/web/js/deluge-bars.js +++ b/deluge/ui/web/js/deluge-bars.js @@ -69,7 +69,7 @@ Deluge.ToolBar = { }, onToolbarRender: function(toolbar) { - Deluge.Connections.on("connect", this.onConnect.bindWithEvent(this)); + Deluge.Events.on("connect", this.onConnect.bindWithEvent(this)); } } diff --git a/deluge/ui/web/js/deluge-connections.js b/deluge/ui/web/js/deluge-connections.js index 2a7210456..d8d6d82ea 100644 --- a/deluge/ui/web/js/deluge-connections.js +++ b/deluge/ui/web/js/deluge-connections.js @@ -1,5 +1,4 @@ Deluge.Connections = { - _events: new Hash(), onClose: function(e) { $clear(Deluge.Connections.running); @@ -16,7 +15,7 @@ Deluge.Connections = { Deluge.Client = new JSON.RPC('/json', { methods: methods }); - Deluge.Connections.fire("connect"); + Deluge.Events.fire("connect"); } }); }, @@ -36,24 +35,6 @@ Deluge.Connections = { Deluge.Connections.runCheck(); }, - fire: function(eventName) { - if (!this._events[eventName]) return; - $each(this._events[eventName], function(fn) { - fn(Deluge.Client); - }); - }, - - on: function(eventName, fn) { - var e = $pick(this._events[eventName], new Array()); - e.include(fn); - this._events[eventName] = e; - }, - - removeListener: function(eventName, fn) { - if (!this._events[eventName]) return; - this._events[eventName].remove(fn); - }, - runCheck: function() { Deluge.Client.web.get_hosts({ onSuccess: Deluge.Connections.onGetHosts diff --git a/deluge/ui/web/js/deluge-ui.js b/deluge/ui/web/js/deluge-ui.js index 586ea1b43..dbe6a98a6 100644 --- a/deluge/ui/web/js/deluge-ui.js +++ b/deluge/ui/web/js/deluge-ui.js @@ -17,7 +17,7 @@ Deluge.Ui = { }); Deluge.Login.Window.show(); - Deluge.Connections.on("connect", this.onConnect.bindWithEvent(this)); + Deluge.Events.on("connect", this.onConnect.bindWithEvent(this)); Deluge.Client = new JSON.RPC('/json'); Deluge.SideBar = this.MainPanel.items.get('sidebar'); diff --git a/deluge/ui/web/js/deluge.js b/deluge/ui/web/js/deluge.js index 6766491e4..ed8548071 100644 --- a/deluge/ui/web/js/deluge.js +++ b/deluge/ui/web/js/deluge.js @@ -1,4 +1,29 @@ -var Deluge = $empty; +var Deluge = { + author: 'Damien Churchill ', + version: '1.2-dev' +}; + +Deluge.Events = { + _events: new Hash(), + + fire: function(eventName) { + if (!this._events[eventName]) return; + $each(this._events[eventName], function(fn) { + fn(Deluge.Client); + }); + }, + + on: function(eventName, fn) { + var e = $pick(this._events[eventName], new Array()); + e.include(fn); + this._events[eventName] = e; + }, + + removeListener: function(eventName, fn) { + if (!this._events[eventName]) return; + this._events[eventName].remove(fn); + } +}; Deluge.Formatters = { size: function(bytes) {