Log client startup errors to console
[KiwiIRC.git] / client / src / app.js
index 087de5f62b248c2871218c5dda17e0e70a59c992..619507cc7e2569c22b6f35c2cf12d77573571142 100644 (file)
@@ -8,6 +8,7 @@ _kiwi.misc = {};
 _kiwi.model = {};\r
 _kiwi.view = {};\r
 _kiwi.applets = {};\r
+_kiwi.utils = {};\r
 \r
 \r
 /**\r
@@ -23,6 +24,7 @@ _kiwi.global = {
     rpc: undefined, // Instance of WebsocketRpc\r
     utils: {}, // References to misc. re-usable helpers / functions\r
 \r
+    // Make public some internal utils for plugins to make use of\r
     initUtils: function() {\r
         this.utils.randomString = randomString;\r
         this.utils.secondsToTime = secondsToTime;\r
@@ -31,6 +33,9 @@ _kiwi.global = {
         this.utils.formatIRCMsg = formatIRCMsg;\r
         this.utils.styleText = styleText;\r
         this.utils.hsl2rgb = hsl2rgb;\r
+\r
+        this.utils.notifications = _kiwi.utils.notifications;\r
+        this.utils.formatDate = _kiwi.utils.formatDate;\r
     },\r
 \r
     addMediaMessageType: function(match, buildHtml) {\r
@@ -114,8 +119,9 @@ _kiwi.global = {
                 kiwi: 'kiwi', raw: 'raw', kick: 'kick', topic: 'topic',\r
                 part: 'part', join: 'join', action: 'action', ctcp: 'ctcp',\r
                 ctcpRequest: 'ctcpRequest', ctcpResponse: 'ctcpResponse',\r
-                notice: 'notice', msg: 'privmsg', changeNick: 'changeNick',\r
-                channelInfo: 'channelInfo', mode: 'mode', quit: 'quit'\r
+                notice: 'notice', msg: 'privmsg', say: 'privmsg',\r
+                changeNick: 'changeNick', channelInfo: 'channelInfo',\r
+                mode: 'mode', quit: 'quit'\r
             };\r
 \r
             _.each(funcs, function(gateway_fn, func_name) {\r
@@ -131,6 +137,18 @@ _kiwi.global = {
                 };\r
             });\r
 \r
+            // Now for some network related functions...\r
+            obj.createQuery = function(nick) {\r
+                var network, restricted_keys;\r
+\r
+                network = getNetwork();\r
+                if (!network) {\r
+                    return;\r
+                }\r
+\r
+                return network.createQuery(nick);\r
+            };\r
+\r
             // Add the networks getters/setters\r
             obj.get = function(name) {\r
                 var network, restricted_keys;\r
@@ -175,6 +193,9 @@ _kiwi.global = {
                 };\r
             });\r
 \r
+            // Give access to the control input textarea\r
+            obj.input = _kiwi.app.controlbox.$('.inp');\r
+\r
             return obj;\r
         }\r
     },\r
@@ -229,6 +250,9 @@ _kiwi.global = {
             _kiwi.global.plugins = new _kiwi.model.PluginManager();\r
 \r
             callback();\r
+\r
+        }).then(null, function(err) {\r
+            console.error(err.stack);\r
         });\r
     },\r
 \r