Merge branch 'development'
[KiwiIRC.git] / client / assets / dev / app.js
1 // Holds anything kiwi client specific (ie. front, gateway, _kiwi.plugs..)
2 /**
3 * @namespace
4 */
5 var _kiwi = {};
6
7 _kiwi.model = {};
8 _kiwi.view = {};
9 _kiwi.applets = {};
10
11
12 /**
13 * A global container for third party access
14 * Will be used to access a limited subset of kiwi functionality
15 * and data (think: plugins)
16 */
17 _kiwi.global = {
18 settings: undefined,
19 plugins: undefined,
20 utils: undefined, // TODO: Re-usable methods
21 gateway: undefined, // TODO: Access to gateway
22 user: undefined, // TODO: Limited user methods
23 server: undefined, // TODO: Limited server methods
24 command: undefined, // The control box
25
26 // TODO: think of a better term for this as it will also refer to queries
27 channels: undefined, // TODO: Limited access to panels list
28
29 // Entry point to start the kiwi application
30 start: function (opts) {
31 opts = opts || {};
32
33 // Load the plugin manager
34 _kiwi.global.plugins = new _kiwi.model.PluginManager();
35
36 // Set up the settings datastore
37 _kiwi.global.settings = _kiwi.model.DataStore.instance('kiwi.settings');
38 _kiwi.global.settings.load();
39
40 _kiwi.app = new _kiwi.model.Application(opts);
41
42 if (opts.kiwi_server) {
43 _kiwi.app.kiwi_server = opts.kiwi_server;
44 }
45
46 // Start the client up
47 _kiwi.app.start();
48
49 return true;
50 }
51 };
52
53
54
55 // If within a closure, expose the kiwi globals
56 if (typeof global !== 'undefined') {
57 global.kiwi = _kiwi.global;
58 } else {
59 // Not within a closure so set a var in the current scope
60 var kiwi = _kiwi.global;
61 }