Switching the old RPC methods to the websocketrpc
[KiwiIRC.git] / client / src / app.js
index 4331567a657be3441f313a912b2444fd7786ce8b..e063bc47b6804faac81f726ad369660608a65c7f 100644 (file)
@@ -18,12 +18,7 @@ _kiwi.global = {
     build_version: '',  // Kiwi IRC version this is built from (Set from index.html)\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
+    utils: {}, // TODO: Re-usable methods\r
 \r
     addMediaMessageType: function(match, buildHtml) {\r
         _kiwi.view.MediaMessage.addType(match, buildHtml);\r
@@ -110,16 +105,11 @@ _kiwi.global = {
 \r
     // Entry point to start the kiwi application\r
     init: function (opts, callback) {\r
-        var continueStart, locale;\r
+        var jobs, locale, localeLoaded, textThemeLoaded, text_theme;\r
         opts = opts || {};\r
 \r
-        continueInit = function (locale, s, xhr) {\r
-            if (locale) {\r
-                _kiwi.global.i18n = new Jed(locale);\r
-            } else {\r
-                _kiwi.global.i18n = new Jed();\r
-            }\r
-\r
+        jobs = new JobManager();\r
+        jobs.onFinish(function(locale, s, xhr) {\r
             _kiwi.app = new _kiwi.model.Application(opts);\r
 \r
             // Start the client up\r
@@ -128,7 +118,23 @@ _kiwi.global = {
             // Now everything has started up, load the plugin manager for third party plugins\r
             _kiwi.global.plugins = new _kiwi.model.PluginManager();\r
 \r
-            callback && callback();\r
+            callback();\r
+        });\r
+\r
+        textThemeLoaded = function(text_theme, s, xhr) {\r
+            opts.text_theme = text_theme;\r
+\r
+            jobs.finishJob('load_text_theme');\r
+        };\r
+\r
+        localeLoaded = function(locale, s, xhr) {\r
+            if (locale) {\r
+                _kiwi.global.i18n = new Jed(locale);\r
+            } else {\r
+                _kiwi.global.i18n = new Jed();\r
+            }\r
+\r
+            jobs.finishJob('load_locale');\r
         };\r
 \r
         // Set up the settings datastore\r
@@ -138,12 +144,17 @@ _kiwi.global = {
         // Set the window title\r
         window.document.title = opts.server_settings.client.window_title || 'Kiwi IRC';\r
 \r
+        jobs.registerJob('load_locale');\r
         locale = _kiwi.global.settings.get('locale');\r
         if (!locale) {\r
-            $.getJSON(opts.base_path + '/assets/locales/magic.json', continueInit);\r
+            $.getJSON(opts.base_path + '/assets/locales/magic.json', localeLoaded);\r
         } else {\r
-            $.getJSON(opts.base_path + '/assets/locales/' + locale + '.json', continueInit);\r
+            $.getJSON(opts.base_path + '/assets/locales/' + locale + '.json', localeLoaded);\r
         }\r
+\r
+        jobs.registerJob('load_text_theme');\r
+        text_theme = opts.server_settings.client.settings.text_theme || 'default';\r
+        $.getJSON(opts.base_path + '/assets/text_themes/' + text_theme + '.json', textThemeLoaded);\r
     },\r
 \r
     start: function() {\r