* and data (think: plugins)\r
*/\r
_kiwi.global = {\r
- settings: undefined, // Instance of _kiwi.model.DataStore\r
- plugins: undefined,\r
- utils: undefined, // TODO: Re-usable methods\r
- user: undefined, // TODO: Limited user methods\r
- server: undefined, // TODO: Limited server methods\r
-\r
- // TODO: think of a better term for this as it will also refer to queries\r
- channels: undefined, // TODO: Limited access to panels list\r
-\r
- // Event managers for plugins\r
- components: {\r
- EventComponent: function(event_source, proxy_event_name) {\r
- function proxyEvent(event_name, event_data) {\r
- if (proxy_event_name !== 'all') {\r
- event_data = event_name.event_data;\r
- event_name = event_name.event_name\r
- }\r
+ settings: undefined, // Instance of _kiwi.model.DataStore\r
+ plugins: undefined,\r
+ utils: undefined, // TODO: Re-usable methods\r
+ user: undefined, // TODO: Limited user methods\r
+ server: undefined, // TODO: Limited server methods\r
+\r
+ // TODO: think of a better term for this as it will also refer to queries\r
+ channels: undefined, // TODO: Limited access to panels list\r
+\r
+ // Event managers for plugins\r
+ components: {\r
+ EventComponent: function(event_source, proxy_event_name) {\r
+ function proxyEvent(event_name, event_data) {\r
+ if (proxy_event_name !== 'all') {\r
+ event_data = event_name.event_data;\r
+ event_name = event_name.event_name\r
+ }\r
//console.log(proxy_event_name, event_name, event_data);\r
- this.trigger(event_name, event_data);\r
- }\r
-\r
- // The event we are to proxy\r
- proxy_event_name = proxy_event_name || 'all';\r
-\r
-\r
- _.extend(this, Backbone.Events);\r
- this._source = event_source;\r
-\r
- // Proxy the events to this dispatcher\r
- event_source.on(proxy_event_name, proxyEvent, this);\r
-\r
- // Clean up this object\r
- this.dispose = function () {\r
- event_source.off(proxy_event_name, proxyEvent);\r
- this.off();\r
- delete this.event_source;\r
- };\r
- },\r
-\r
- Network: function(connection_id) {\r
- var connection_event;\r
-\r
- if (typeof connection_id !== 'undefined') {\r
- connection_event = 'connection:' + connection_id.toString();\r
- }\r
-\r
- var obj = new this.EventComponent(_kiwi.gateway, connection_event);\r
- var funcs = {\r
- kiwi: 'kiwi', raw: 'raw', kick: 'kick', topic: 'topic',\r
- part: 'part', join: 'join', action: 'action', ctcp: 'ctcp',\r
- notice: 'notice', msg: 'privmsg', changeNick: 'changeNick'\r
- };\r
-\r
- // Proxy each gateway method\r
- _.each(funcs, function(gateway_fn, func_name) {\r
- obj[func_name] = function() {\r
- var fn_name = gateway_fn;\r
-\r
- // Add connection_id to the argument list\r
- var args = Array.prototype.slice.call(arguments, 0);\r
- args.unshift(connection_id);\r
-\r
- // Call the gateway function on behalf of this connection\r
- return _kiwi.gateway[fn_name].apply(_kiwi.gateway, args);\r
- };\r
- });\r
-\r
- return obj;\r
- },\r
-\r
- ControlInput: function() {\r
- var obj = new this.EventComponent(_kiwi.app.controlbox);\r
- var funcs = {\r
- processInput: 'run', addPluginIcon: 'addPluginIcon'\r
- };\r
-\r
- _.each(funcs, function(controlbox_fn, func_name) {\r
- obj[func_name] = function() {\r
- var fn_name = controlbox_fn;\r
- return _kiwi.app.controlbox[fn_name].apply(_kiwi.app.controlbox, arguments);\r
- };\r
- });\r
-\r
- return obj;\r
- }\r
- },\r
-\r
- // Entry point to start the kiwi application\r
- start: function (opts) {\r
- var continueStart, locale;\r
- opts = opts || {};\r
+ this.trigger(event_name, event_data);\r
+ }\r
+\r
+ // The event we are to proxy\r
+ proxy_event_name = proxy_event_name || 'all';\r
+\r
+\r
+ _.extend(this, Backbone.Events);\r
+ this._source = event_source;\r
+\r
+ // Proxy the events to this dispatcher\r
+ event_source.on(proxy_event_name, proxyEvent, this);\r
+\r
+ // Clean up this object\r
+ this.dispose = function () {\r
+ event_source.off(proxy_event_name, proxyEvent);\r
+ this.off();\r
+ delete this.event_source;\r
+ };\r
+ },\r
+\r
+ Network: function(connection_id) {\r
+ var connection_event;\r
+\r
+ if (typeof connection_id !== 'undefined') {\r
+ connection_event = 'connection:' + connection_id.toString();\r
+ }\r
+\r
+ var obj = new this.EventComponent(_kiwi.gateway, connection_event);\r
+ var funcs = {\r
+ kiwi: 'kiwi', raw: 'raw', kick: 'kick', topic: 'topic',\r
+ part: 'part', join: 'join', action: 'action', ctcp: 'ctcp',\r
+ notice: 'notice', msg: 'privmsg', changeNick: 'changeNick'\r
+ };\r
+\r
+ // Proxy each gateway method\r
+ _.each(funcs, function(gateway_fn, func_name) {\r
+ obj[func_name] = function() {\r
+ var fn_name = gateway_fn;\r
+\r
+ // Add connection_id to the argument list\r
+ var args = Array.prototype.slice.call(arguments, 0);\r
+ args.unshift(connection_id);\r
+\r
+ // Call the gateway function on behalf of this connection\r
+ return _kiwi.gateway[fn_name].apply(_kiwi.gateway, args);\r
+ };\r
+ });\r
+\r
+ return obj;\r
+ },\r
+\r
+ ControlInput: function() {\r
+ var obj = new this.EventComponent(_kiwi.app.controlbox);\r
+ var funcs = {\r
+ processInput: 'run', addPluginIcon: 'addPluginIcon'\r
+ };\r
+\r
+ _.each(funcs, function(controlbox_fn, func_name) {\r
+ obj[func_name] = function() {\r
+ var fn_name = controlbox_fn;\r
+ return _kiwi.app.controlbox[fn_name].apply(_kiwi.app.controlbox, arguments);\r
+ };\r
+ });\r
+\r
+ return obj;\r
+ }\r
+ },\r
+\r
+ // Entry point to start the kiwi application\r
+ start: function (opts) {\r
+ var continueStart, locale;\r
+ opts = opts || {};\r
\r
// Load the plugin manager\r
_kiwi.global.plugins = new _kiwi.model.PluginManager();\r
_kiwi.global.settings.load();\r
\r
continueStart = function (locale, s, xhr) {\r
- if (locale) {\r
- _kiwi.global.i18n = new Jed({locale_data: locale, domain: xhr.getResponseHeader('Content-Language')});\r
- } else {\r
- _kiwi.global.i18n = new Jed();\r
- }\r
+ if (locale) {\r
+ _kiwi.global.i18n = new Jed({locale_data: locale, domain: xhr.getResponseHeader('Content-Language')});\r
+ } else {\r
+ _kiwi.global.i18n = new Jed();\r
+ }\r
\r
- _kiwi.app = new _kiwi.model.Application(opts);\r
+ _kiwi.app = new _kiwi.model.Application(opts);\r
\r
- if (opts.kiwi_server) {\r
- _kiwi.app.kiwi_server = opts.kiwi_server;\r
- }\r
+ if (opts.kiwi_server) {\r
+ _kiwi.app.kiwi_server = opts.kiwi_server;\r
+ }\r
\r
- // Start the client up\r
- _kiwi.app.start();\r
+ // Start the client up\r
+ _kiwi.app.start();\r
};\r
\r
locale = _kiwi.global.settings.get('locale')\r
if (!locale) {\r
- $.getJSON(opts.base_path + '/assets/locales/magic.json', continueStart);\r
+ $.getJSON(opts.base_path + '/assets/locales/magic.json', continueStart);\r
} else {\r
- $.getJSON(opts.base_path + '/assets/locales/' + locale + '.json', continueStart);\r
+ $.getJSON(opts.base_path + '/assets/locales/' + locale + '.json', continueStart);\r
}\r
- }\r
+ }\r
};\r
\r
\r
\r
// If within a closure, expose the kiwi globals\r
if (typeof global !== 'undefined') {\r
- global.kiwi = _kiwi.global;\r
+ global.kiwi = _kiwi.global;\r
} else {\r
- // Not within a closure so set a var in the current scope\r
- var kiwi = _kiwi.global;\r
+ // Not within a closure so set a var in the current scope\r
+ var kiwi = _kiwi.global;\r
}
\ No newline at end of file