-(function (window) {
+(function (global) {
// Holds anything kiwi client specific (ie. front, gateway, kiwi.plugs..)\r
/**\r
* @namespace\r
*/\r
-var kiwi = window.kiwi = {};\r
+var kiwi = {};\r
\r
kiwi.model = {};\r
kiwi.view = {};\r
/**\r
* A global container for third party access\r
* Will be used to access a limited subset of kiwi functionality\r
- * and data\r
+ * and data (think: plugins)\r
*/\r
-if (typeof global === 'undefined') {\r
- global = {};\r
-}\r
-\r
-global.kiwi = {\r
+kiwi.global = {\r
gateway: undefined,\r
user: undefined,\r
server: undefined,\r
channels: undefined,\r
\r
+ // Entry point to start the kiwi application\r
+ start: function (opts) {\r
+ opts = opts || {};\r
+\r
+ kiwi.app = new kiwi.model.Application(opts);\r
+\r
+ if (opts.kiwi_server) {\r
+ kiwi.app.kiwi_server = opts.kiwi_server;\r
+ }\r
+\r
+ kiwi.app.start();\r
+\r
+ return true;\r
+ },\r
+\r
utils: undefined // Re-usable methods\r
-};
+};\r
+\r
+\r
+\r
+// If within a closure, expose the kiwi globals\r
+if (typeof global !== 'undefined') {\r
+ global.kiwi = kiwi.global;\r
+}
kiwi.model.Application = Backbone.Model.extend(new (function () {\r
this.socket.on('connect', function () {\r
this.emit('irc connect', that.get('nick'), host, port, ssl, password, callback);\r
that.trigger('connect', {});\r
- console.log("kiwi.gateway.socket.on('connect')", host, port);\r
});\r
\r
this.socket.on('too_many_connections', function () {\r
* Parses the response from the server\r
*/\r
this.parse = function (item) {\r
- console.log('gateway event', item);\r
+ //console.log('gateway event', item);\r
if (item.event !== undefined) {\r
that.trigger('on' + item.event, item);\r
\r
/*jslint white:true, regexp: true, nomen: true, devel: true, undef: true, browser: true, continue: true, sloppy: true, forin: true, newcap: true, plusplus: true, maxerr: 50, indent: 4 */\r
/*global kiwi */\r
\r
-kiwi.view = {};\r
-\r
kiwi.view.MemberList = Backbone.View.extend({\r
tagName: "ul",\r
events: {\r