Removing old client files
authorDarren <darren@darrenwhitlen.com>
Mon, 22 Oct 2012 18:32:04 +0000 (19:32 +0100)
committerDarren <darren@darrenwhitlen.com>
Mon, 22 Oct 2012 18:32:04 +0000 (19:32 +0100)
16 files changed:
client/dev/app.js [deleted file]
client/dev/applet_chanlist.js [deleted file]
client/dev/applet_nickserv.js [deleted file]
client/dev/applet_settings.js [deleted file]
client/dev/build.js [deleted file]
client/dev/model_applet.js [deleted file]
client/dev/model_application.js [deleted file]
client/dev/model_channel.js [deleted file]
client/dev/model_gateway.js [deleted file]
client/dev/model_member.js [deleted file]
client/dev/model_memberlist.js [deleted file]
client/dev/model_panel.js [deleted file]
client/dev/model_panellist.js [deleted file]
client/dev/model_server.js [deleted file]
client/dev/utils.js [deleted file]
client/dev/view.js [deleted file]

diff --git a/client/dev/app.js b/client/dev/app.js
deleted file mode 100644 (file)
index c680b41..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// Holds anything kiwi client specific (ie. front, gateway, kiwi.plugs..)\r
-/**\r
-*   @namespace\r
-*/\r
-var kiwi = {};\r
-\r
-kiwi.model = {};\r
-kiwi.view = {};\r
-kiwi.applets = {};\r
-\r
-\r
-/**\r
- * A global container for third party access\r
- * Will be used to access a limited subset of kiwi functionality\r
- * and data (think: plugins)\r
- */\r
-kiwi.global = {\r
-       utils: undefined, // Re-usable methods\r
-       gateway: undefined,\r
-       user: undefined,\r
-       server: undefined,\r
-       command: undefined,  // The control box\r
-\r
-       // TODO: think of a better term for this as it will also refer to queries\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
-\r
-\r
-\r
-// If within a closure, expose the kiwi globals\r
-if (typeof global !== 'undefined') {\r
-       global.kiwi = kiwi.global;\r
-}
\ No newline at end of file
diff --git a/client/dev/applet_chanlist.js b/client/dev/applet_chanlist.js
deleted file mode 100644 (file)
index 8898a2c..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-(function () {\r
-\r
-    var View = Backbone.View.extend({\r
-        events: {\r
-        },\r
-\r
-\r
-\r
-        initialize: function (options) {\r
-            this.$el = $($('#tmpl_channel_list').html());\r
-\r
-            this.channels = [];\r
-\r
-            // Sort the table by num. users?\r
-            this.ordered = false;\r
-\r
-            // Waiting to add the table back into the DOM?\r
-            this.waiting = false;\r
-        },\r
-\r
-\r
-        render: function () {\r
-            var table = $('table', this.$el),\r
-                tbody = table.children('tbody:first').detach();\r
-            /*tbody.children().each(function (child) {\r
-                var i, chan;\r
-                child = $(child);\r
-                chan = child.children('td:first').text();\r
-                for (i = 0; i < chanList.length; i++) {\r
-                    if (chanList[i].channel === chan) {\r
-                        chanList[i].html = child.detach();\r
-                        break;\r
-                    }\r
-                }\r
-            });*/\r
-\r
-            if (this.ordered) {\r
-                this.channels.sort(function (a, b) {\r
-                    return b.num_users - a.num_users;\r
-                });\r
-            }\r
-\r
-            _.each(this.channels, function (chan) {\r
-                tbody.append(chan.html);\r
-            });\r
-            table.append(tbody);\r
-        }\r
-    });\r
-\r
-\r
-\r
-\r
-    kiwi.applets.Chanlist = Backbone.Model.extend({\r
-        initialize: function () {\r
-            this.set('title', 'Channel List');\r
-            this.view = new View();\r
-        },\r
-\r
-\r
-        addChannel: function (channels) {\r
-            var that = this;\r
-\r
-            if (!_.isArray(channels)) {\r
-                channels = [channels];\r
-            }\r
-            _.each(channels, function (chan) {\r
-                var html, channel;\r
-                html = '<tr><td><a class="chan">' + chan.channel + '</a></td><td class="num_users" style="text-align: center;">' + chan.num_users + '</td><td style="padding-left: 2em;">' + formatIRCMsg(chan.topic) + '</td></tr>';\r
-                chan.html = html;\r
-                that.view.channels.push(chan);\r
-            });\r
-\r
-            if (!that.view.waiting) {\r
-                that.view.waiting = true;\r
-                _.defer(function () {\r
-                    that.view.render();\r
-                    that.view.waiting = false;\r
-                });\r
-            }\r
-        },\r
-\r
-\r
-        dispose: function () {\r
-            this.view.channels = null;\r
-            this.view.unbind();\r
-            this.view.$el.html('');\r
-            this.view.remove();\r
-            this.view = null;\r
-        }\r
-    });\r
-\r
-\r
-})();
\ No newline at end of file
diff --git a/client/dev/applet_nickserv.js b/client/dev/applet_nickserv.js
deleted file mode 100644 (file)
index 0244d1d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-(function () {\r
-    var View = Backbone.View.extend({\r
-        events: {\r
-            'click .save': 'saveSettings'\r
-        },\r
-\r
-        initialize: function (options) {\r
-            this.$el = $($('#tmpl_applet_settings').html());\r
-        },\r
-        \r
-        saveSettings: function () {\r
-            var theme = $('.theme', this.$el).val(),\r
-                containers = $('#panels > .panel_container');\r
-\r
-            // Clear any current theme\r
-            containers.removeClass(function (i, css) {\r
-                return (css.match (/\btheme_\S+/g) || []).join(' ');\r
-            });\r
-\r
-            if (theme) containers.addClass('theme_' + theme);\r
-        }\r
-    });\r
-\r
-\r
-\r
-    kiwi.applets.nickserv = Backbone.Model.extend({\r
-        initialize: function () {\r
-            this.set('title', 'Nickserv Login');\r
-            //this.view = new View();\r
-\r
-            kiwi.global.control.on('command_login', this.loginCommand, this);\r
-        },\r
-\r
-        loginCommand: function (event) {\r
-            console.log('waheeyy');\r
-        }\r
-    });\r
-})();
\ No newline at end of file
diff --git a/client/dev/applet_settings.js b/client/dev/applet_settings.js
deleted file mode 100644 (file)
index 6b97d0f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-(function () {\r
-    var View = Backbone.View.extend({\r
-        events: {\r
-            'click .save': 'saveSettings'\r
-        },\r
-\r
-        initialize: function (options) {\r
-            this.$el = $($('#tmpl_applet_settings').html());\r
-        },\r
-        \r
-        saveSettings: function () {\r
-            var theme = $('.theme', this.$el).val();\r
-\r
-            // Clear any current theme\r
-            kiwi.app.view.$el.removeClass(function (i, css) {\r
-                return (css.match (/\btheme_\S+/g) || []).join(' ');\r
-            });\r
-\r
-            if (theme) kiwi.app.view.$el.addClass('theme_' + theme);\r
-        }\r
-    });\r
-\r
-\r
-\r
-    kiwi.applets.Settings = Backbone.Model.extend({\r
-        initialize: function () {\r
-            this.set('title', 'Settings');\r
-            this.view = new View();\r
-        }\r
-    });\r
-})();
\ No newline at end of file
diff --git a/client/dev/build.js b/client/dev/build.js
deleted file mode 100644 (file)
index a8270fa..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-var fs = require('fs');\r
-var uglyfyJS = require('uglify-js');\r
-\r
-var FILE_ENCODING = 'utf-8',\r
-    EOL = '\n';\r
-\r
-\r
-function concat(src) {\r
-    var file_list = src;\r
-    var out = file_list.map(function(file_path){\r
-        return fs.readFileSync(file_path, FILE_ENCODING) + '\n\n';\r
-    });\r
-\r
-    return out.join(EOL);\r
-}\r
-\r
-var src = concat([\r
-    __dirname + '/app.js',\r
-    __dirname + '/model_application.js',\r
-    __dirname + '/model_gateway.js',\r
-    __dirname + '/model_member.js',\r
-    __dirname + '/model_memberlist.js',\r
-    __dirname + '/model_panel.js',\r
-    __dirname + '/model_panellist.js',\r
-    __dirname + '/model_channel.js',\r
-    __dirname + '/model_server.js',\r
-    __dirname + '/model_applet.js',\r
-\r
-    __dirname + '/applet_settings.js',\r
-    __dirname + '/applet_nickserv.js',\r
-    __dirname + '/applet_chanlist.js',\r
-\r
-    __dirname + '/utils.js',\r
-    __dirname + '/view.js'\r
-]);\r
-\r
-\r
-src = '(function (global) {\n\n' + src + '\n\n})(window);';\r
-\r
-\r
-fs.writeFileSync(__dirname + '/../kiwi.js', src, FILE_ENCODING);\r
-\r
-\r
-src = uglyfyJS.parser.parse(src);\r
-src = uglyfyJS.uglify.ast_mangle(src);\r
-src = uglyfyJS.uglify.ast_squeeze(src);\r
-fs.writeFileSync(__dirname + '/../kiwi.min.js', uglyfyJS.uglify.gen_code(src), FILE_ENCODING);\r
-\r
-\r
-\r
-\r
-console.log(' kiwi.js and kiwi.min.js built');
\ No newline at end of file
diff --git a/client/dev/model_applet.js b/client/dev/model_applet.js
deleted file mode 100644 (file)
index cf337e6..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-kiwi.model.Applet = kiwi.model.Panel.extend({\r
-    // Used to determine if this is an applet panel. Applet panel tabs are treated\r
-    // differently than others\r
-    applet: true,\r
-\r
-\r
-    initialize: function (attributes) {\r
-        // Temporary name\r
-        var name = "applet_"+(new Date().getTime().toString()) + Math.ceil(Math.random()*100).toString();\r
-        this.view = new kiwi.view.Applet({model: this, name: name});\r
-\r
-        this.set({\r
-            "name": name\r
-        }, {"silent": true});\r
-\r
-        // Holds the loaded applet\r
-        this.loaded_applet = null;\r
-    },\r
-\r
-    // Load an applet within this panel\r
-    load: function (applet_object, applet_name) {\r
-        if (typeof applet_object === 'object') {\r
-            // Make sure this is a valid Applet\r
-            if (applet_object.get || applet_object.extend) {\r
-\r
-                // Try find a title for the applet\r
-                this.set('title', applet_object.get('title') || 'Unknown Applet');\r
-\r
-                // Update the tabs title if the applet changes it\r
-                applet_object.bind('change:title', function (obj, new_value) {\r
-                    this.set('title', new_value);\r
-                }, this);\r
-\r
-                // If this applet has a UI, add it now\r
-                this.view.$el.html('');\r
-                if (applet_object.view) {\r
-                    this.view.$el.append(applet_object.view.$el);\r
-                }\r
-\r
-                // Keep a reference to this applet\r
-                this.loaded_applet = applet_object;\r
-            }\r
-\r
-        } else if (typeof applet_object === 'string') {\r
-            // Treat this as a URL to an applet script and load it\r
-            this.loadFromUrl(applet_object, applet_name);\r
-        }\r
-\r
-        return this;\r
-    },\r
-\r
-    loadFromUrl: function(applet_url, applet_name) {\r
-        var that = this;\r
-\r
-        this.view.$el.html('Loading..');\r
-        $script(applet_url, function () {\r
-            // Check if the applet loaded OK\r
-            if (!kiwi.applets[applet_name]) {\r
-                that.view.$el.html('Not found');\r
-                return;\r
-            }\r
-\r
-            // Load a new instance of this applet\r
-            that.load(new kiwi.applets[applet_name]());\r
-        });\r
-    },\r
-\r
-    close: function () {\r
-        this.view.$el.remove();\r
-        this.destroy();\r
-        \r
-        this.view = undefined;\r
-\r
-        // Call the applets dispose method if it has one\r
-        if (this.loaded_applet && this.loaded_applet.dispose) {\r
-            this.loaded_applet.dispose();\r
-        }\r
-\r
-        this.closePanel();\r
-    }\r
-});
\ No newline at end of file
diff --git a/client/dev/model_application.js b/client/dev/model_application.js
deleted file mode 100644 (file)
index 1f4e0e5..0000000
+++ /dev/null
@@ -1,898 +0,0 @@
-kiwi.model.Application = function () {\r
-    // Set to a reference to this object within initialize()\r
-    var that = null;\r
-\r
-    // The auto connect details entered into the server select box\r
-    var auto_connect_details = {};\r
-\r
-\r
-    var model = function () {\r
-        /** Instance of kiwi.model.PanelList */\r
-        this.panels = null;\r
-\r
-        /** kiwi.view.Application */\r
-        this.view = null;\r
-\r
-        /** kiwi.view.StatusMessage */\r
-        this.message = null;\r
-\r
-        /* Address for the kiwi server */\r
-        this.kiwi_server = null;\r
-\r
-        this.initialize = function (options) {\r
-            that = this;\r
-\r
-            if (options[0].container) {\r
-                this.set('container', options[0].container);\r
-            }\r
-\r
-            // Best guess at where the kiwi server is\r
-            this.detectKiwiServer();\r
-        };\r
-\r
-        this.start = function () {\r
-            // Only debug if set in the querystring\r
-            if (!getQueryVariable('debug')) {\r
-                manageDebug(false);\r
-            } else {\r
-                //manageDebug(true);\r
-            }\r
-            \r
-            // Set the gateway up\r
-            kiwi.gateway = new kiwi.model.Gateway();\r
-            this.bindGatewayCommands(kiwi.gateway);\r
-\r
-            this.initializeClient();\r
-            this.initializeGlobals();\r
-\r
-            this.view.barsHide(true);\r
-\r
-            this.panels.server.server_login.bind('server_connect', function (event) {\r
-                var server_login = this;\r
-                auto_connect_details = event;\r
-\r
-                server_login.networkConnecting();\r
-                \r
-                $script(that.kiwi_server + '/socket.io/socket.io.js?ts='+(new Date().getTime()), function () {\r
-                    if (!window.io) {\r
-                        kiwiServerNotFound();\r
-                        return;\r
-                    }\r
-                    kiwi.gateway.set('kiwi_server', that.kiwi_server + '/kiwi');\r
-                    kiwi.gateway.set('nick', event.nick);\r
-                    \r
-                    kiwi.gateway.connect(event.server, event.port, event.ssl, event.password, function () {});\r
-                });\r
-            });\r
-\r
-            // TODO: Shouldn't really be here but it's not working in the view.. :/\r
-            // Hack for firefox browers: Focus is not given on this event loop iteration\r
-            setTimeout(function(){\r
-                kiwi.app.panels.server.server_login.$el.find('.nick').select();\r
-            }, 0);\r
-        };\r
-\r
-\r
-        function kiwiServerNotFound (e) {\r
-            that.panels.server.server_login.showError();\r
-        }\r
-\r
-\r
-        this.detectKiwiServer = function () {\r
-            // If running from file, default to localhost:7777 by default\r
-            if (window.location.protocol === 'file:') {\r
-                this.kiwi_server = 'http://localhost:7778';\r
-            } else {\r
-                // Assume the kiwi server is on the same server\r
-                this.kiwi_server = window.location.protocol + '//' + window.location.host;\r
-            }\r
-        };\r
-\r
-\r
-        this.initializeClient = function () {\r
-            this.view = new kiwi.view.Application({model: this, el: this.get('container')});\r
-            \r
-            /**\r
-             * Set the UI components up\r
-             */\r
-            this.panels = new kiwi.model.PanelList();\r
-\r
-            this.controlbox = new kiwi.view.ControlBox({el: $('#controlbox')[0]});\r
-            this.bindControllboxCommands(this.controlbox);\r
-\r
-            this.topicbar = new kiwi.view.TopicBar({el: $('#topic')[0]});\r
-\r
-            this.message = new kiwi.view.StatusMessage({el: $('#status_message')[0]});\r
-\r
-            this.resize_handle = new kiwi.view.ResizeHandler({el: $('#memberlists_resize_handle')[0]});\r
-            \r
-            this.panels.server.view.show();\r
-\r
-            // Rejigg the UI sizes\r
-            this.view.doLayout();\r
-\r
-            this.populateDefaultServerSettings();\r
-        };\r
-\r
-\r
-        this.initializeGlobals = function () {\r
-            kiwi.global.control = this.controlbox;\r
-        };\r
-\r
-\r
-        this.populateDefaultServerSettings = function () {\r
-            var parts;\r
-            var defaults = {\r
-                nick: getQueryVariable('nick') || 'kiwi_' + Math.ceil(Math.random() * 10000).toString(),\r
-                server: 'irc.kiwiirc.com',\r
-                port: 6667,\r
-                ssl: false,\r
-                channel: window.location.hash || '#kiwiirc'\r
-            };\r
-\r
-            // Process the URL part by part, extracting as we go\r
-            parts = window.location.pathname.toString().split('/');\r
-            parts.shift();\r
-\r
-            if (parts.length > 0 && parts[0].toLowerCase() === 'client') {\r
-                parts.shift();\r
-\r
-                if (parts.length > 0 && parts[0]) {\r
-                    // TODO: Extract the port from this hostname\r
-                    defaults.server = parts[0];\r
-                    parts.shift();\r
-                }\r
-\r
-                if (parts.length > 0 && parts[0]) {\r
-                    defaults.channel = '#' + parts[0];\r
-                    parts.shift();\r
-                }\r
-            }\r
-\r
-            // Set any random numbers if needed\r
-            defaults.nick = defaults.nick.replace('?', Math.floor(Math.random() * 100000).toString());\r
-\r
-            // Populate the server select box with defaults\r
-            this.panels.server.server_login.populateFields(defaults);\r
-        };\r
-\r
-\r
-        this.bindGatewayCommands = function (gw) {\r
-            gw.on('onmotd', function (event) {\r
-                that.panels.server.addMsg(kiwi.gateway.get('name'), event.msg, 'motd');\r
-            });\r
-\r
-\r
-            gw.on('onconnect', function (event) {\r
-                that.view.barsShow();\r
-                \r
-                if (auto_connect_details.channel) {\r
-                    that.controlbox.processInput('/JOIN ' + auto_connect_details.channel);\r
-                }\r
-            });\r
-\r
-\r
-            (function () {\r
-                var gw_stat = 0;\r
-\r
-                gw.on('disconnect', function (event) {\r
-                    var msg = 'You have been disconnected. Attempting to reconnect for you..';\r
-                    that.message.text(msg, {timeout: 10000});\r
-\r
-                    // Mention the disconnection on every channel\r
-                    $.each(kiwi.app.panels.models, function (idx, panel) {\r
-                        if (!panel || !panel.isChannel()) return;\r
-                        panel.addMsg('', msg, 'action quit');\r
-                    });\r
-                    kiwi.app.panels.server.addMsg('', msg, 'action quit');\r
-\r
-                    gw_stat = 1;\r
-                });\r
-                gw.on('reconnecting', function (event) {\r
-                    msg = 'You have been disconnected. Attempting to reconnect again in ' + (event.delay/1000) + ' seconds..';\r
-                    kiwi.app.panels.server.addMsg('', msg, 'action quit');\r
-                });\r
-                gw.on('connect', function (event) {\r
-                    if (gw_stat !== 1) return;\r
-\r
-                    var msg = 'It\'s OK, you\'re connected again :)';\r
-                    that.message.text(msg, {timeout: 5000});\r
-\r
-                    // Mention the disconnection on every channel\r
-                    $.each(kiwi.app.panels.models, function (idx, panel) {\r
-                        if (!panel || !panel.isChannel()) return;\r
-                        panel.addMsg('', msg, 'action join');\r
-                    });\r
-                    kiwi.app.panels.server.addMsg('', msg, 'action join');\r
-\r
-                    gw_stat = 0;\r
-                });\r
-            })();\r
-\r
-\r
-            gw.on('onjoin', function (event) {\r
-                var c, members, user;\r
-                c = that.panels.getByName(event.channel);\r
-                if (!c) {\r
-                    c = new kiwi.model.Channel({name: event.channel});\r
-                    that.panels.add(c);\r
-                }\r
-\r
-                members = c.get('members');\r
-                if (!members) return;\r
-\r
-                user = new kiwi.model.Member({nick: event.nick, ident: event.ident, hostname: event.hostname});\r
-                members.add(user);\r
-                // TODO: highlight the new channel in some way\r
-            });\r
-\r
-\r
-            gw.on('onpart', function (event) {\r
-                var channel, members, user,\r
-                    part_options = {};\r
-\r
-                part_options.type = 'part';\r
-                part_options.message = event.message || '';\r
-\r
-                channel = that.panels.getByName(event.channel);\r
-                if (!channel) return;\r
-\r
-                // If this is us, close the panel\r
-                if (event.nick === kiwi.gateway.get('nick')) {\r
-                    channel.close();\r
-                    return;\r
-                }\r
-\r
-                members = channel.get('members');\r
-                if (!members) return;\r
-\r
-                user = members.getByNick(event.nick);\r
-                if (!user) return;\r
-\r
-                members.remove(user, part_options);\r
-            });\r
-\r
-\r
-            gw.on('onquit', function (event) {\r
-                var member, members,\r
-                    quit_options = {};\r
-\r
-                quit_options.type = 'quit';\r
-                quit_options.message = event.message || '';\r
-\r
-                $.each(that.panels.models, function (index, panel) {\r
-                    if (!panel.isChannel()) return;\r
-\r
-                    member = panel.get('members').getByNick(event.nick);\r
-                    if (member) {\r
-                        panel.get('members').remove(member, quit_options);\r
-                    }\r
-                });\r
-            });\r
-\r
-\r
-            gw.on('onkick', function (event) {\r
-                var channel, members, user,\r
-                    part_options = {};\r
-\r
-                part_options.type = 'kick';\r
-                part_options.by = event.nick;\r
-                part_options.message = event.message || '';\r
-\r
-                channel = that.panels.getByName(event.channel);\r
-                if (!channel) return;\r
-\r
-                members = channel.get('members');\r
-                if (!members) return;\r
-\r
-                user = members.getByNick(event.kicked);\r
-                if (!user) return;\r
-\r
-                members.remove(user, part_options);\r
-\r
-                if (event.kicked === kiwi.gateway.get('nick')) {\r
-                    members.reset([]);\r
-                }\r
-                \r
-            });\r
-\r
-\r
-            gw.on('onmsg', function (event) {\r
-                var panel,\r
-                    is_pm = (event.channel == kiwi.gateway.get('nick'));\r
-\r
-                if (is_pm) {\r
-                    // If a panel isn't found for this PM, create one\r
-                    panel = that.panels.getByName(event.nick);\r
-                    if (!panel) {\r
-                        panel = new kiwi.model.Channel({name: event.nick});\r
-                        that.panels.add(panel);\r
-                    }\r
-\r
-                } else {\r
-                    // If a panel isn't found for this channel, reroute to the\r
-                    // server panel\r
-                    panel = that.panels.getByName(event.channel);\r
-                    if (!panel) {\r
-                        panel = that.panels.server;\r
-                    }\r
-                }\r
-                \r
-                panel.addMsg(event.nick, event.msg);\r
-            });\r
-\r
-\r
-            gw.on('onnotice', function (event) {\r
-                var panel;\r
-\r
-                // Find a panel for the destination(channel) or who its from\r
-                panel = that.panels.getByName(event.target) || that.panels.getByName(event.nick);\r
-                if (!panel) {\r
-                    panel = that.panels.server;\r
-                }\r
-\r
-                panel.addMsg('[' + (event.nick||'') + ']', event.msg);\r
-            });\r
-\r
-\r
-            gw.on('onaction', function (event) {\r
-                var panel,\r
-                    is_pm = (event.channel == kiwi.gateway.get('nick'));\r
-\r
-                if (is_pm) {\r
-                    // If a panel isn't found for this PM, create one\r
-                    panel = that.panels.getByName(event.nick);\r
-                    if (!panel) {\r
-                        panel = new kiwi.model.Channel({name: event.nick});\r
-                        that.panels.add(panel);\r
-                    }\r
-\r
-                } else {\r
-                    // If a panel isn't found for this channel, reroute to the\r
-                    // server panel\r
-                    panel = that.panels.getByName(event.channel);\r
-                    if (!panel) {\r
-                        panel = that.panels.server;\r
-                    }\r
-                }\r
-\r
-                panel.addMsg('', '* ' + event.nick + ' ' + event.msg, 'action');\r
-            });\r
-\r
-\r
-            gw.on('ontopic', function (event) {\r
-                var c;\r
-                c = that.panels.getByName(event.channel);\r
-                if (!c) return;\r
-\r
-                // Set the channels topic\r
-                c.set('topic', event.topic);\r
-\r
-                // If this is the active channel, update the topic bar too\r
-                if (c.get('name') === kiwi.app.panels.active.get('name')) {\r
-                    that.topicbar.setCurrentTopic(event.topic);\r
-                }\r
-            });\r
-\r
-\r
-            gw.on('ontopicsetby', function (event) {\r
-                var c, when;\r
-                c = that.panels.getByName(event.channel);\r
-                if (!c) return;\r
-\r
-                when = formatDate(new Date(event.when * 1000));\r
-                c.addMsg('', 'Topic set by ' + event.nick + ' at ' + when, 'topic');\r
-            });\r
-\r
-\r
-            gw.on('onuserlist', function (event) {\r
-                var channel;\r
-                channel = that.panels.getByName(event.channel);\r
-\r
-                // If we didn't find a channel for this, may aswell leave\r
-                if (!channel) return;\r
-\r
-                channel.temp_userlist = channel.temp_userlist || [];\r
-                _.each(event.users, function (item) {\r
-                    var user = new kiwi.model.Member({nick: item.nick, modes: item.modes});\r
-                    channel.temp_userlist.push(user);\r
-                });\r
-            });\r
-\r
-\r
-            gw.on('onuserlist_end', function (event) {\r
-                var channel;\r
-                channel = that.panels.getByName(event.channel);\r
-\r
-                // If we didn't find a channel for this, may aswell leave\r
-                if (!channel) return;\r
-\r
-                // Update the members list with the new list\r
-                channel.get('members').reset(channel.temp_userlist || []);\r
-\r
-                // Clear the temporary userlist\r
-                delete channel.temp_userlist;\r
-            });\r
-\r
-\r
-            gw.on('onmode', function (event) {\r
-                var channel, i, prefixes, members, member, find_prefix;\r
-                \r
-                // Build a nicely formatted string to be displayed to a regular human\r
-                function friendlyModeString (event_modes, alt_target) {\r
-                    var modes = {}, return_string;\r
-\r
-                    // If no default given, use the main event info\r
-                    if (!event_modes) {\r
-                        event_modes = event.modes;\r
-                        alt_target = event.target;\r
-                    }\r
-\r
-                    // Reformat the mode object to make it easier to work with\r
-                    _.each(event_modes, function (mode){\r
-                        var param = mode.param || alt_target || '';\r
-\r
-                        // Make sure we have some modes for this param\r
-                        if (!modes[param]) {\r
-                            modes[param] = {'+':'', '-':''};\r
-                        }\r
-\r
-                        modes[param][mode.mode[0]] += mode.mode.substr(1);\r
-                    });\r
-\r
-                    // Put the string together from each mode\r
-                    return_string = [];\r
-                    _.each(modes, function (modeset, param) {\r
-                        var str = '';\r
-                        if (modeset['+']) str += '+' + modeset['+'];\r
-                        if (modeset['-']) str += '-' + modeset['-'];\r
-                        return_string.push(str + ' ' + param);\r
-                    });\r
-                    return_string = return_string.join(', ');\r
-\r
-                    return return_string;\r
-                }\r
-\r
-\r
-                channel = that.panels.getByName(event.target);\r
-                if (channel) {\r
-                    prefixes = kiwi.gateway.get('user_prefixes');\r
-                    find_prefix = function (p) {\r
-                        return event.modes[i].mode[1] === p.mode;\r
-                    };\r
-                    for (i = 0; i < event.modes.length; i++) {\r
-                        if (_.any(prefixes, find_prefix)) {\r
-                            if (!members) {\r
-                                members = channel.get('members');\r
-                            }\r
-                            member = members.getByNick(event.modes[i].param);\r
-                            if (!member) {\r
-                                console.log('MODE command recieved for unknown member %s on channel %s', event.modes[i].param, event.target);\r
-                                return;\r
-                            } else {\r
-                                if (event.modes[i].mode[0] === '+') {\r
-                                    member.addMode(event.modes[i].mode[1]);\r
-                                } else if (event.modes[i].mode[0] === '-') {\r
-                                    member.removeMode(event.modes[i].mode[1]);\r
-                                }\r
-                                members.sort();\r
-                                //channel.addMsg('', '== ' + event.nick + ' set mode ' + event.modes[i].mode + ' ' + event.modes[i].param, 'action mode');\r
-                            }\r
-                        } else {\r
-                            // Channel mode being set\r
-                            // TODO: Store this somewhere?\r
-                            //channel.addMsg('', 'CHANNEL === ' + event.nick + ' set mode ' + event.modes[i].mode + ' on ' + event.target, 'action mode');\r
-                        }\r
-                    }\r
-\r
-                    channel.addMsg('', '== ' + event.nick + ' sets mode ' + friendlyModeString(), 'action mode');\r
-                } else {\r
-                    // This is probably a mode being set on us.\r
-                    if (event.target.toLowerCase() === kiwi.gateway.get("nick").toLowerCase()) {\r
-                        that.panels.server.addMsg('', '== ' + event.nick + ' set mode ' + friendlyModeString(), 'action mode');\r
-                    } else {\r
-                       console.log('MODE command recieved for unknown target %s: ', event.target, event);\r
-                    }\r
-                }\r
-            });\r
-\r
-\r
-            gw.on('onnick', function (event) {\r
-                var member;\r
-\r
-                $.each(that.panels.models, function (index, panel) {\r
-                    if (!panel.isChannel()) return;\r
-\r
-                    member = panel.get('members').getByNick(event.nick);\r
-                    if (member) {\r
-                        member.set('nick', event.newnick);\r
-                        panel.addMsg('', '== ' + event.nick + ' is now known as ' + event.newnick, 'action nick');\r
-                    }\r
-                });\r
-            });\r
-\r
-\r
-            gw.on('onwhois', function (event) {\r
-                /*globals secondsToTime */\r
-                var logon_date, idle_time = '', panel;\r
-\r
-                if (event.end) {\r
-                    return;\r
-                }\r
-\r
-                if (typeof event.idle !== 'undefined') {\r
-                    idle_time = secondsToTime(parseInt(event.idle, 10));\r
-                    idle_time = idle_time.h.toString().lpad(2, "0") + ':' + idle_time.m.toString().lpad(2, "0") + ':' + idle_time.s.toString().lpad(2, "0");\r
-                }\r
-\r
-                panel = kiwi.app.panels.active;\r
-                if (event.ident) {\r
-                    panel.addMsg(event.nick, 'is ' + event.nick + '!' + event.ident + '@' + event.host + ' * ' + event.msg, 'whois');\r
-                } else if (event.chans) {\r
-                    panel.addMsg(event.nick, 'on ' + event.chans, 'whois');\r
-                } else if (event.server) {\r
-                    panel.addMsg(event.nick, 'using ' + event.server, 'whois');\r
-                } else if (event.msg) {\r
-                    panel.addMsg(event.nick, event.msg, 'whois');\r
-                } else if (event.logon) {\r
-                    logon_date = new Date();\r
-                    logon_date.setTime(event.logon * 1000);\r
-                    logon_date = formatDate(logon_date);\r
-\r
-                    panel.addMsg(event.nick, 'idle for ' + idle_time + ', signed on ' + logon_date, 'whois');\r
-                } else {\r
-                    panel.addMsg(event.nick, 'idle for ' + idle_time, 'whois');\r
-                }\r
-            });\r
-\r
-\r
-            gw.on('onlist_start', function (data) {\r
-                if (kiwi.app.channel_list) {\r
-                    kiwi.app.channel_list.close();\r
-                    delete kiwi.app.channel_list;\r
-                }\r
-\r
-                var panel = new kiwi.model.Applet(),\r
-                    applet = new kiwi.applets.Chanlist();\r
-\r
-                panel.load(applet);\r
-                \r
-                kiwi.app.panels.add(panel);\r
-                panel.view.show();\r
-                \r
-                kiwi.app.channel_list = applet;\r
-            });\r
-\r
-\r
-            gw.on('onlist_channel', function (data) {\r
-                // TODO: Put this listener within the applet itself\r
-                kiwi.app.channel_list.addChannel(data.chans);\r
-            });\r
-\r
-\r
-            gw.on('onlist_end', function (data) {\r
-                // TODO: Put this listener within the applet itself\r
-                delete kiwi.app.channel_list;\r
-            });\r
-\r
-\r
-            gw.on('onirc_error', function (data) {\r
-                var panel, tmp;\r
-\r
-                if (data.channel !== undefined && !(panel = kiwi.app.panels.getByName(data.channel))) {\r
-                    panel = kiwi.app.panels.server;\r
-                }\r
-\r
-                switch (data.error) {\r
-                case 'banned_from_channel':\r
-                    panel.addMsg(' ', '== You are banned from ' + data.channel + '. ' + data.reason, 'status');\r
-                    kiwi.app.message.text('You are banned from ' + data.channel + '. ' + data.reason);\r
-                    break;\r
-                case 'bad_channel_key':\r
-                    panel.addMsg(' ', '== Bad channel key for ' + data.channel, 'status');\r
-                    kiwi.app.message.text('Bad channel key or password for ' + data.channel);\r
-                    break;\r
-                case 'invite_only_channel':\r
-                    panel.addMsg(' ', '== ' + data.channel + ' is invite only.', 'status');\r
-                    kiwi.app.message.text(data.channel + ' is invite only');\r
-                    break;\r
-                case 'channel_is_full':\r
-                    panel.addMsg(' ', '== ' + data.channel + ' is full.', 'status');\r
-                    kiwi.app.message.text(data.channel + ' is full');\r
-                    break;\r
-                case 'chanop_privs_needed':\r
-                    panel.addMsg(' ', '== ' + data.reason, 'status');\r
-                    kiwi.app.message.text(data.reason + ' (' + data.channel + ')');\r
-                    break;\r
-                case 'no_such_nick':\r
-                    tmp = kiwi.app.panels.getByName(data.nick);\r
-                    if (tmp) {\r
-                        tmp.addMsg(' ', '== ' + data.nick + ': ' + data.reason, 'status');\r
-                    } else {\r
-                        kiwi.app.panels.server.addMsg(' ', '== ' + data.nick + ': ' + data.reason, 'status');\r
-                    }\r
-                    break;\r
-                case 'nickname_in_use':\r
-                    kiwi.app.panels.server.addMsg(' ', '== The nickname ' + data.nick + ' is already in use. Please select a new nickname', 'status');\r
-                    if (kiwi.app.panels.server !== kiwi.app.panels.active) {\r
-                        kiwi.app.message.text('The nickname "' + data.nick + '" is already in use. Please select a new nickname');\r
-                    }\r
-\r
-                    // Only show the nickchange component if the controlbox is open\r
-                    if (that.controlbox.$el.css('display') !== 'none') {\r
-                        (new kiwi.view.NickChangeBox()).render();\r
-                    }\r
-\r
-                    break;\r
-                default:\r
-                    // We don't know what data contains, so don't do anything with it.\r
-                    //kiwi.front.tabviews.server.addMsg(null, ' ', '== ' + data, 'status');\r
-                }\r
-            });\r
-        };\r
-\r
-\r
-\r
-        /**\r
-         * Bind to certain commands that may be typed into the control box\r
-         */\r
-        this.bindControllboxCommands = function (controlbox) {\r
-            // Default aliases\r
-            $.extend(controlbox.preprocessor.aliases, {\r
-                '/p': '/part $1+',\r
-                '/me': '/action $1+',\r
-                '/j': '/join $1+',\r
-                '/q': '/query $1+',\r
-                '/k': '/kick $1+',\r
-\r
-                '/slap': '/me throws the juciest, sweetest kiwi at $1. Hits right in the kisser!',\r
-                '/throw': '/slap $1+'\r
-            });\r
-\r
-            controlbox.on('unknown_command', unknownCommand);\r
-\r
-            controlbox.on('command', allCommands);\r
-            controlbox.on('command_msg', msgCommand);\r
-\r
-            controlbox.on('command_action', actionCommand);\r
-\r
-            controlbox.on('command_join', joinCommand);\r
-\r
-            controlbox.on('command_part', partCommand);\r
-\r
-            controlbox.on('command_nick', function (ev) {\r
-                kiwi.gateway.changeNick(ev.params[0]);\r
-            });\r
-\r
-            controlbox.on('command_query', queryCommand);\r
-\r
-            controlbox.on('command_topic', topicCommand);\r
-\r
-            controlbox.on('command_notice', noticeCommand);\r
-\r
-            controlbox.on('command_quote', quoteCommand);\r
-\r
-            controlbox.on('command_kick', kickCommand);\r
-\r
-\r
-            controlbox.on('command_css', function (ev) {\r
-                var queryString = '?reload=' + new Date().getTime();\r
-                $('link[rel="stylesheet"]').each(function () {\r
-                    this.href = this.href.replace(/\?.*|$/, queryString);\r
-                });\r
-            });\r
-\r
-            controlbox.on('command_js', function (ev) {\r
-                if (!ev.params[0]) return;\r
-                $script(ev.params[0] + '?' + (new Date().getTime()));\r
-            });\r
-\r
-            controlbox.on('command_alias', function (ev) {\r
-                var name, rule;\r
-\r
-                // No parameters passed so list them\r
-                if (!ev.params[1]) {\r
-                    $.each(controlbox.preprocessor.aliases, function (name, rule) {\r
-                        kiwi.app.panels.server.addMsg(' ', name + '   =>   ' + rule);\r
-                    });\r
-                    return;\r
-                }\r
-\r
-                // Deleting an alias?\r
-                if (ev.params[0] === 'del' || ev.params[0] === 'delete') {\r
-                    name = ev.params[1];\r
-                    if (name[0] !== '/') name = '/' + name;\r
-                    delete controlbox.preprocessor.aliases[name];\r
-                    return;\r
-                }\r
-\r
-                // Add the alias\r
-                name = ev.params[0];\r
-                ev.params.shift();\r
-                rule = ev.params.join(' ');\r
-\r
-                // Make sure the name starts with a slash\r
-                if (name[0] !== '/') name = '/' + name;\r
-\r
-                // Now actually add the alias\r
-                controlbox.preprocessor.aliases[name] = rule;\r
-            });\r
-\r
-            controlbox.on('command_applet', appletCommand);\r
-            controlbox.on('command_settings', settingsCommand);\r
-        };\r
-\r
-        // A fallback action. Send a raw command to the server\r
-        function unknownCommand (ev) {\r
-            var raw_cmd = ev.command + ' ' + ev.params.join(' ');\r
-            console.log('RAW: ' + raw_cmd);\r
-            kiwi.gateway.raw(raw_cmd);\r
-        }\r
-\r
-        function allCommands (ev) {}\r
-\r
-        function joinCommand (ev) {\r
-            var channel, channel_names;\r
-\r
-            channel_names = ev.params.join(' ').split(',');\r
-\r
-            $.each(channel_names, function (index, channel_name) {\r
-                // Trim any whitespace off the name\r
-                channel_name = channel_name.trim();\r
-\r
-                // Check if we have the panel already. If not, create it\r
-                channel = that.panels.getByName(channel_name);\r
-                if (!channel) {\r
-                    channel = new kiwi.model.Channel({name: channel_name});\r
-                    kiwi.app.panels.add(channel);\r
-                }\r
-\r
-                kiwi.gateway.join(channel_name);\r
-            });\r
-\r
-            if (channel) channel.view.show();\r
-            \r
-        }\r
-\r
-        function queryCommand (ev) {\r
-            var destination, panel;\r
-\r
-            destination = ev.params[0];\r
-\r
-            // Check if we have the panel already. If not, create it\r
-            panel = that.panels.getByName(destination);\r
-            if (!panel) {\r
-                panel = new kiwi.model.Channel({name: destination});\r
-                kiwi.app.panels.add(panel);\r
-            }\r
-\r
-            if (panel) panel.view.show();\r
-            \r
-        }\r
-\r
-        function msgCommand (ev) {\r
-            var destination = ev.params[0],\r
-                panel = that.panels.getByName(destination) || that.panels.server;\r
-\r
-            ev.params.shift();\r
-\r
-            panel.addMsg(kiwi.gateway.get('nick'), ev.params.join(' '));\r
-            kiwi.gateway.privmsg(destination, ev.params.join(' '));\r
-        }\r
-\r
-        function actionCommand (ev) {\r
-            if (kiwi.app.panels.active === kiwi.app.panels.server) {\r
-                return;\r
-            }\r
-\r
-            var panel = kiwi.app.panels.active;\r
-            panel.addMsg('', '* ' + kiwi.gateway.get('nick') + ' ' + ev.params.join(' '), 'action');\r
-            kiwi.gateway.action(panel.get('name'), ev.params.join(' '));\r
-        }\r
-\r
-        function partCommand (ev) {\r
-            if (ev.params.length === 0) {\r
-                kiwi.gateway.part(kiwi.app.panels.active.get('name'));\r
-            } else {\r
-                _.each(ev.params, function (channel) {\r
-                    kiwi.gateway.part(channel);\r
-                });\r
-            }\r
-            // TODO: More responsive = close tab now, more accurate = leave until part event\r
-            //kiwi.app.panels.remove(kiwi.app.panels.active);\r
-        }\r
-\r
-        function topicCommand (ev) {\r
-            var channel_name;\r
-\r
-            if (ev.params.length === 0) return;\r
-\r
-            if (that.isChannelName(ev.params[0])) {\r
-                channel_name = ev.params[0];\r
-                ev.params.shift();\r
-            } else {\r
-                channel_name = kiwi.app.panels.active.get('name');\r
-            }\r
-\r
-            kiwi.gateway.topic(channel_name, ev.params.join(' '));\r
-        }\r
-\r
-        function noticeCommand (ev) {\r
-            var destination;\r
-\r
-            // Make sure we have a destination and some sort of message\r
-            if (ev.params.length <= 1) return;\r
-\r
-            destination = ev.params[0];\r
-            ev.params.shift();\r
-\r
-            kiwi.gateway.notice(destination, ev.params.join(' '));\r
-        }\r
-\r
-        function quoteCommand (ev) {\r
-            var raw = ev.params.join(' ');\r
-            kiwi.gateway.raw(raw);\r
-        }\r
-\r
-        function kickCommand (ev) {\r
-            var nick, panel = kiwi.app.panels.active;\r
-\r
-            if (!panel.isChannel()) return;\r
-\r
-            // Make sure we have a nick\r
-            if (ev.params.length === 0) return;\r
-\r
-            nick = ev.params[0];\r
-            ev.params.shift();\r
-\r
-            kiwi.gateway.kick(panel.get('name'), nick, ev.params.join(' '));\r
-        }\r
-\r
-        function settingsCommand (ev) {\r
-            var panel = new kiwi.model.Applet();\r
-            panel.load(new kiwi.applets.Settings());\r
-            \r
-            kiwi.app.panels.add(panel);\r
-            panel.view.show();\r
-        }\r
-\r
-        function appletCommand (ev) {\r
-            if (!ev.params[0]) return;\r
-\r
-            var panel = new kiwi.model.Applet();\r
-\r
-            if (ev.params[1]) {\r
-                // Url and name given\r
-                panel.load(ev.params[0], ev.params[1]);\r
-            } else {\r
-                // Load a pre-loaded applet\r
-                if (kiwi.applets[ev.params[0]]) {\r
-                    panel.load(new kiwi.applets[ev.params[0]]());\r
-                } else {\r
-                    kiwi.app.panels.server.addMsg('', 'Applet "' + ev.params[0] + '" does not exist');\r
-                    return;\r
-                }\r
-            }\r
-            \r
-            kiwi.app.panels.add(panel);\r
-            panel.view.show();\r
-        }\r
-\r
-\r
-\r
-\r
-\r
-        this.isChannelName = function (channel_name) {\r
-            var channel_prefix = kiwi.gateway.get('channel_prefix');\r
-\r
-            if (!channel_name || !channel_name.length) return false;\r
-            return (channel_prefix.indexOf(channel_name[0]) > -1);\r
-        };\r
-\r
-    };\r
-\r
-\r
-    model = Backbone.Model.extend(new model());\r
-\r
-    return new model(arguments);\r
-};\r
diff --git a/client/dev/model_channel.js b/client/dev/model_channel.js
deleted file mode 100644 (file)
index 9819bb9..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// TODO: Channel modes\r
-// TODO: Listen to gateway events for anythign related to this channel\r
-kiwi.model.Channel = kiwi.model.Panel.extend({\r
-    initialize: function (attributes) {\r
-        var name = this.get("name") || "",\r
-            members;\r
-\r
-        this.view = new kiwi.view.Channel({"model": this, "name": name});\r
-        this.set({\r
-            "members": new kiwi.model.MemberList(),\r
-            "name": name,\r
-            "scrollback": [],\r
-            "topic": ""\r
-        }, {"silent": true});\r
-\r
-        members = this.get("members");\r
-        members.bind("add", function (member) {\r
-            this.addMsg(' ', '== ' + member.displayNick(true) + ' has joined', 'action join');\r
-        }, this);\r
-\r
-        members.bind("remove", function (member, members, options) {\r
-            var msg = (options.message) ? '(' + options.message + ')' : '';\r
-\r
-            if (options.type === 'quit') {\r
-                this.addMsg(' ', '== ' + member.displayNick(true) + ' has quit ' + msg, 'action quit');\r
-            } else if(options.type === 'kick') {\r
-                this.addMsg(' ', '== ' + member.displayNick(true) + ' was kicked by ' + options.by + ' ' + msg, 'action kick');\r
-            } else {\r
-                this.addMsg(' ', '== ' + member.displayNick(true) + ' has left ' + msg, 'action part');\r
-            }\r
-        }, this);\r
-    }\r
-});
\ No newline at end of file
diff --git a/client/dev/model_gateway.js b/client/dev/model_gateway.js
deleted file mode 100644 (file)
index dba907f..0000000
+++ /dev/null
@@ -1,427 +0,0 @@
-kiwi.model.Gateway = function () {\r
-\r
-    // Set to a reference to this object within initialize()\r
-    var that = null;\r
-\r
-    this.defaults = {\r
-        /**\r
-        *   The name of the network\r
-        *   @type    String\r
-        */\r
-        name: 'Server',\r
-\r
-        /**\r
-        *   The address (URL) of the network\r
-        *   @type    String\r
-        */\r
-        address: '',\r
-\r
-        /**\r
-        *   The current nickname\r
-        *   @type   String\r
-        */\r
-        nick: '',\r
-\r
-        /**\r
-        *   The channel prefix for this network\r
-        *   @type    String\r
-        */\r
-        channel_prefix: '#',\r
-\r
-        /**\r
-        *   The user prefixes for channel owner/admin/op/voice etc. on this network\r
-        *   @type   Array\r
-        */\r
-        user_prefixes: ['~', '&', '@', '+'],\r
-\r
-        /**\r
-        *   The URL to the Kiwi server\r
-        *   @type   String\r
-        */\r
-        kiwi_server: '//kiwi'\r
-    };\r
-\r
-\r
-    this.initialize = function () {\r
-        that = this;\r
-        \r
-        // For ease of access. The socket.io object\r
-        this.socket = this.get('socket');\r
-    };\r
-\r
-\r
-    /**\r
-    *   Connects to the server\r
-    *   @param  {String}    host        The hostname or IP address of the IRC server to connect to\r
-    *   @param  {Number}    port        The port of the IRC server to connect to\r
-    *   @param  {Boolean}   ssl         Whether or not to connect to the IRC server using SSL\r
-    *   @param  {String}    password    The password to supply to the IRC server during registration\r
-    *   @param  {Function}  callback    A callback function to be invoked once Kiwi's server has connected to the IRC server\r
-    */\r
-    this.connect = function (host, port, ssl, password, callback) {\r
-        this.socket = io.connect(this.get('kiwi_server'), {\r
-            'try multiple transports': true,\r
-            'connect timeout': 3000,\r
-            'max reconnection attempts': 7,\r
-            'reconnection delay': 2000,\r
-            'sync disconnect on unload': false\r
-        });\r
-        this.socket.on('connect_failed', function (reason) {\r
-            // TODO: When does this even actually get fired? I can't find a case! ~Darren\r
-            console.debug('Unable to connect Socket.IO', reason);\r
-            console.log("kiwi.gateway.socket.on('connect_failed')");\r
-            //kiwi.front.tabviews.server.addMsg(null, ' ', 'Unable to connect to Kiwi IRC.\n' + reason, 'error');\r
-            this.socket.disconnect();\r
-            this.trigger("connect_fail", {reason: reason});\r
-        });\r
-\r
-        this.socket.on('error', function (e) {\r
-            this.trigger("connect_fail", {reason: e});\r
-            console.log("kiwi.gateway.socket.on('error')", {reason: e});\r
-        });\r
-\r
-        this.socket.on('connecting', function (transport_type) {\r
-            console.log("kiwi.gateway.socket.on('connecting')");\r
-            that.trigger("connecting");\r
-        });\r
-\r
-        /**\r
-         * Once connected to the kiwi server send the IRC connect command along\r
-         * with the IRC server details.\r
-         * A `connect` event is sent from the kiwi server once connected to the\r
-         * IRCD and the nick has been accepted.\r
-         */\r
-        this.socket.on('connect', function () {\r
-            this.emit('kiwi', {command: 'connect', nick: that.get('nick'), hostname: host, port: port, ssl: ssl, password:password}, function (err, server_num) {\r
-                if (!err) {\r
-                    that.server_num = server_num;\r
-                    console.log("kiwi.gateway.socket.on('connect')");\r
-                } else {\r
-                    console.log("kiwi.gateway.socket.on('error')", {reason: err});\r
-                }\r
-            });\r
-        });\r
-\r
-        this.socket.on('too_many_connections', function () {\r
-            this.trigger("connect_fail", {reason: 'too_many_connections'});\r
-        });\r
-\r
-        this.socket.on('irc', function (data, callback) {\r
-            that.parse(data.command, data.data);\r
-        });\r
-\r
-        this.socket.on('disconnect', function () {\r
-            that.trigger("disconnect", {});\r
-            console.log("kiwi.gateway.socket.on('disconnect')");\r
-        });\r
-\r
-        this.socket.on('close', function () {\r
-            console.log("kiwi.gateway.socket.on('close')");\r
-        });\r
-\r
-        this.socket.on('reconnecting', function (reconnectionDelay, reconnectionAttempts) {\r
-            console.log("kiwi.gateway.socket.on('reconnecting')");\r
-            that.trigger("reconnecting", {delay: reconnectionDelay, attempts: reconnectionAttempts});\r
-        });\r
-\r
-        this.socket.on('reconnect_failed', function () {\r
-            console.log("kiwi.gateway.socket.on('reconnect_failed')");\r
-        });\r
-    };\r
-\r
-\r
-\r
-    this.isConnected = function () {\r
-        return this.socket.socket.connected;\r
-    };\r
-\r
-\r
-    /*\r
-        Events:\r
-            msg\r
-            action\r
-            server_connect\r
-            options\r
-            motd\r
-            notice\r
-            userlist\r
-            nick\r
-            join\r
-            topic\r
-            part\r
-            kick\r
-            quit\r
-            whois\r
-            syncchannel_redirect\r
-            debug\r
-    */\r
-    /**\r
-    *   Parses the response from the server\r
-    */\r
-    this.parse = function (command, data) {\r
-        console.log('gateway event', command, data);\r
-        if (command !== undefined) {\r
-            that.trigger('on' + command, data);\r
-\r
-            switch (command) {\r
-            case 'options':\r
-                $.each(data.options, function (name, value) {\r
-                    switch (name) {\r
-                    case 'CHANTYPES':\r
-                        // TODO: Check this. Why is it only getting the first char?\r
-                        that.set('channel_prefix', value.join('').charAt(0));\r
-                        break;\r
-                    case 'NETWORK':\r
-                        that.set('name', value);\r
-                        break;\r
-                    case 'PREFIX':\r
-                        that.set('user_prefixes', value);\r
-                        break;\r
-                    }\r
-                });\r
-                break;\r
-\r
-            case 'connect':\r
-                that.set('nick', data.nick);\r
-                break;\r
-\r
-            case 'nick':\r
-                if (data.nick === that.get('nick')) {\r
-                    that.set('nick', data.newnick);\r
-                }\r
-                break;\r
-            /*\r
-            case 'sync':\r
-                if (kiwi.gateway.onSync && kiwi.gateway.syncing) {\r
-                    kiwi.gateway.syncing = false;\r
-                    kiwi.gateway.onSync(item);\r
-                }\r
-                break;\r
-            */\r
-\r
-            case 'kiwi':\r
-                this.emit('kiwi.' + data.namespace, data.data);\r
-                break;\r
-            }\r
-        }\r
-    };\r
-\r
-    /**\r
-    *   Sends data to the server\r
-    *   @private\r
-    *   @param  {Object}    data        The data to send\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.sendData = function (data, callback) {\r
-        this.socket.emit('irc', {server: 0, data: JSON.stringify(data)}, callback);\r
-    };\r
-\r
-    /**\r
-    *   Sends a PRIVMSG message\r
-    *   @param  {String}    target      The target of the message (e.g. a channel or nick)\r
-    *   @param  {String}    msg         The message to send\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.privmsg = function (target, msg, callback) {\r
-        var data = {\r
-            method: 'privmsg',\r
-            args: {\r
-                target: target,\r
-                msg: msg\r
-            }\r
-        };\r
-\r
-        this.sendData(data, callback);\r
-    };\r
-\r
-    /**\r
-    *   Sends a NOTICE message\r
-    *   @param  {String}    target      The target of the message (e.g. a channel or nick)\r
-    *   @param  {String}    msg         The message to send\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.notice = function (target, msg, callback) {\r
-        var data = {\r
-            method: 'notice',\r
-            args: {\r
-                target: target,\r
-                msg: msg\r
-            }\r
-        };\r
-\r
-        this.sendData(data, callback);\r
-    };\r
-\r
-    /**\r
-    *   Sends a CTCP message\r
-    *   @param  {Boolean}   request     Indicates whether this is a CTCP request (true) or reply (false)\r
-    *   @param  {String}    type        The type of CTCP message, e.g. 'VERSION', 'TIME', 'PING' etc.\r
-    *   @param  {String}    target      The target of the message, e.g a channel or nick\r
-    *   @param  {String}    params      Additional paramaters\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.ctcp = function (request, type, target, params, callback) {\r
-        var data = {\r
-            method: 'ctcp',\r
-            args: {\r
-                request: request,\r
-                type: type,\r
-                target: target,\r
-                params: params\r
-            }\r
-        };\r
-\r
-        this.sendData(data, callback);\r
-    };\r
-\r
-    /**\r
-    *   @param  {String}    target      The target of the message (e.g. a channel or nick)\r
-    *   @param  {String}    msg         The message to send\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.action = function (target, msg, callback) {\r
-        this.ctcp(true, 'ACTION', target, msg, callback);\r
-    };\r
-\r
-    /**\r
-    *   Joins a channel\r
-    *   @param  {String}    channel     The channel to join\r
-    *   @param  {String}    key         The key to the channel\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.join = function (channel, key, callback) {\r
-        var data = {\r
-            method: 'join',\r
-            args: {\r
-                channel: channel,\r
-                key: key\r
-            }\r
-        };\r
-\r
-        this.sendData(data, callback);\r
-    };\r
-\r
-    /**\r
-    *   Leaves a channel\r
-    *   @param  {String}    channel     The channel to part\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.part = function (channel, callback) {\r
-        var data = {\r
-            method: 'part',\r
-            args: {\r
-                channel: channel\r
-            }\r
-        };\r
-\r
-        this.sendData(data, callback);\r
-    };\r
-\r
-    /**\r
-    *   Queries or modifies a channell topic\r
-    *   @param  {String}    channel     The channel to query or modify\r
-    *   @param  {String}    new_topic   The new topic to set\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.topic = function (channel, new_topic, callback) {\r
-        var data = {\r
-            method: 'topic',\r
-            args: {\r
-                channel: channel,\r
-                topic: new_topic\r
-            }\r
-        };\r
-\r
-        this.sendData(data, callback);\r
-    };\r
-\r
-    /**\r
-    *   Kicks a user from a channel\r
-    *   @param  {String}    channel     The channel to kick the user from\r
-    *   @param  {String}    nick        The nick of the user to kick\r
-    *   @param  {String}    reason      The reason for kicking the user\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.kick = function (channel, nick, reason, callback) {\r
-        var data = {\r
-            method: 'kick',\r
-            args: {\r
-                channel: channel,\r
-                nick: nick,\r
-                reason: reason\r
-            }\r
-        };\r
-\r
-        this.sendData(data, callback);\r
-    };\r
-\r
-    /**\r
-    *   Disconnects us from the server\r
-    *   @param  {String}    msg         The quit message to send to the IRC server\r
-    *   @param  {Function}   callback    A callback function\r
-    */\r
-    this.quit = function (msg, callback) {\r
-        msg = msg || "";\r
-        var data = {\r
-            method: 'quit',\r
-            args: {\r
-                message: msg\r
-            }\r
-        };\r
-\r
-        this.sendData(data, callback);\r
-    };\r
-\r
-    /**\r
-    *   Sends a string unmodified to the IRC server\r
-    *   @param  {String}    data        The data to send to the IRC server\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.raw = function (data, callback) {\r
-        data = {\r
-            method: 'raw',\r
-            args: {\r
-                data: data\r
-            }\r
-        };\r
-\r
-        this.sendData(data, callback);\r
-    };\r
-\r
-    /**\r
-    *   Changes our nickname\r
-    *   @param  {String}    new_nick    Our new nickname\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.changeNick = function (new_nick, callback) {\r
-        var data = {\r
-            method: 'nick',\r
-            args: {\r
-                nick: new_nick\r
-            }\r
-        };\r
-\r
-        this.sendData(data, callback);\r
-    };\r
-\r
-    /**\r
-    *   Sends data to a fellow Kiwi IRC user\r
-    *   @param  {String}    target      The nick of the Kiwi IRC user to send to\r
-    *   @param  {String}    data        The data to send\r
-    *   @param  {Function}  callback    A callback function\r
-    */\r
-    this.kiwi = function (target, data, callback) {\r
-        data = {\r
-            method: 'kiwi',\r
-            args: {\r
-                target: target,\r
-                data: data\r
-            }\r
-        };\r
-\r
-        this.sendData(data, callback);\r
-    };\r
-\r
-\r
-    return new (Backbone.Model.extend(this))(arguments);\r
-};
\ No newline at end of file
diff --git a/client/dev/model_member.js b/client/dev/model_member.js
deleted file mode 100644 (file)
index 535f906..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-kiwi.model.Member = Backbone.Model.extend({\r
-    sortModes: function (modes) {\r
-        return modes.sort(function (a, b) {\r
-            var a_idx, b_idx, i;\r
-            var user_prefixes = kiwi.gateway.get('user_prefixes');\r
-\r
-            for (i = 0; i < user_prefixes.length; i++) {\r
-                if (user_prefixes[i].mode === a) {\r
-                    a_idx = i;\r
-                }\r
-            }\r
-            for (i = 0; i < user_prefixes.length; i++) {\r
-                if (user_prefixes[i].mode === b) {\r
-                    b_idx = i;\r
-                }\r
-            }\r
-            if (a_idx < b_idx) {\r
-                return -1;\r
-            } else if (a_idx > b_idx) {\r
-                return 1;\r
-            } else {\r
-                return 0;\r
-            }\r
-        });\r
-    },\r
-    initialize: function (attributes) {\r
-        var nick, modes, prefix;\r
-        nick = this.stripPrefix(this.get("nick"));\r
-\r
-        modes = this.get("modes");\r
-        modes = modes || [];\r
-        this.sortModes(modes);\r
-        this.set({"nick": nick, "modes": modes, "prefix": this.getPrefix(modes)}, {silent: true});\r
-    },\r
-    addMode: function (mode) {\r
-        var modes_to_add = mode.split(''),\r
-            modes, prefix;\r
-\r
-        modes = this.get("modes");\r
-        $.each(modes_to_add, function (index, item) {\r
-            modes.push(item);\r
-        });\r
-        \r
-        modes = this.sortModes(modes);\r
-        this.set({"prefix": this.getPrefix(modes), "modes": modes});\r
-    },\r
-    removeMode: function (mode) {\r
-        var modes_to_remove = mode.split(''),\r
-            modes, prefix;\r
-\r
-        modes = this.get("modes");\r
-        modes = _.reject(modes, function (m) {\r
-            return (_.indexOf(modes_to_remove, m) !== -1);\r
-        });\r
-\r
-        this.set({"prefix": this.getPrefix(modes), "modes": modes});\r
-    },\r
-    getPrefix: function (modes) {\r
-        var prefix = '';\r
-        var user_prefixes = kiwi.gateway.get('user_prefixes');\r
-\r
-        if (typeof modes[0] !== 'undefined') {\r
-            prefix = _.detect(user_prefixes, function (prefix) {\r
-                return prefix.mode === modes[0];\r
-            });\r
-            prefix = (prefix) ? prefix.symbol : '';\r
-        }\r
-        return prefix;\r
-    },\r
-    stripPrefix: function (nick) {\r
-        var tmp = nick, i, j, k;\r
-        var user_prefixes = kiwi.gateway.get('user_prefixes');\r
-        i = 0;\r
-\r
-        for (j = 0; j < nick.length; j++) {\r
-            for (k = 0; k < user_prefixes.length; k++) {\r
-                if (nick.charAt(j) === user_prefixes[k].symbol) {\r
-                    i++;\r
-                    break;\r
-                }\r
-            }\r
-        }\r
-\r
-        return tmp.substr(i);\r
-    },\r
-    displayNick: function (full) {\r
-        var display = this.get('nick');\r
-\r
-        if (full) {\r
-            if (this.get("ident")) {\r
-                display += ' [' + this.get("ident") + '@' + this.get("hostname") + ']';\r
-            }\r
-        }\r
-\r
-        return display;\r
-    }\r
-});
\ No newline at end of file
diff --git a/client/dev/model_memberlist.js b/client/dev/model_memberlist.js
deleted file mode 100644 (file)
index 5e2c0eb..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-kiwi.model.MemberList = Backbone.Collection.extend({\r
-    model: kiwi.model.Member,\r
-    comparator: function (a, b) {\r
-        var i, a_modes, b_modes, a_idx, b_idx, a_nick, b_nick;\r
-        var user_prefixes = kiwi.gateway.get('user_prefixes');\r
-        a_modes = a.get("modes");\r
-        b_modes = b.get("modes");\r
-        // Try to sort by modes first\r
-        if (a_modes.length > 0) {\r
-            // a has modes, but b doesn't so a should appear first\r
-            if (b_modes.length === 0) {\r
-                return -1;\r
-            }\r
-            a_idx = b_idx = -1;\r
-            // Compare the first (highest) mode\r
-            for (i = 0; i < user_prefixes.length; i++) {\r
-                if (user_prefixes[i].mode === a_modes[0]) {\r
-                    a_idx = i;\r
-                }\r
-            }\r
-            for (i = 0; i < user_prefixes.length; i++) {\r
-                if (user_prefixes[i].mode === b_modes[0]) {\r
-                    b_idx = i;\r
-                }\r
-            }\r
-            if (a_idx < b_idx) {\r
-                return -1;\r
-            } else if (a_idx > b_idx) {\r
-                return 1;\r
-            }\r
-            // If we get to here both a and b have the same highest mode so have to resort to lexicographical sorting\r
-\r
-        } else if (b_modes.length > 0) {\r
-            // b has modes but a doesn't so b should appear first\r
-            return 1;\r
-        }\r
-        a_nick = a.get("nick").toLocaleUpperCase();\r
-        b_nick = b.get("nick").toLocaleUpperCase();\r
-        // Lexicographical sorting\r
-        if (a_nick < b_nick) {\r
-            return -1;\r
-        } else if (a_nick > b_nick) {\r
-            return 1;\r
-        } else {\r
-            return 0;\r
-        }\r
-    },\r
-    initialize: function (options) {\r
-        this.view = new kiwi.view.MemberList({"model": this});\r
-    },\r
-    getByNick: function (nick) {\r
-        if (typeof nick !== 'string') return;\r
-        return this.find(function (m) {\r
-            return nick.toLowerCase() === m.get('nick').toLowerCase();\r
-        });\r
-    }\r
-});
\ No newline at end of file
diff --git a/client/dev/model_panel.js b/client/dev/model_panel.js
deleted file mode 100644 (file)
index 1b05f89..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-kiwi.model.Panel = Backbone.Model.extend({\r
-    initialize: function (attributes) {\r
-        var name = this.get("name") || "";\r
-        this.view = new kiwi.view.Panel({"model": this, "name": name});\r
-        this.set({\r
-            "scrollback": [],\r
-            "name": name\r
-        }, {"silent": true});\r
-    },\r
-\r
-    addMsg: function (nick, msg, type, opts) {\r
-        var message_obj, bs, d;\r
-\r
-        opts = opts || {};\r
-\r
-        // Time defaults to now\r
-        if (!opts || typeof opts.time === 'undefined') {\r
-            d = new Date();\r
-            opts.time = d.getHours().toString().lpad(2, "0") + ":" + d.getMinutes().toString().lpad(2, "0") + ":" + d.getSeconds().toString().lpad(2, "0");\r
-        }\r
-\r
-        // CSS style defaults to empty string\r
-        if (!opts || typeof opts.style === 'undefined') {\r
-            opts.style = '';\r
-        }\r
-\r
-        // Run through the plugins\r
-        message_obj = {"msg": msg, "time": opts.time, "nick": nick, "chan": this.get("name"), "type": type, "style": opts.style};\r
-        //tmp = kiwi.plugs.run('addmsg', message_obj);\r
-        if (!message_obj) {\r
-            return;\r
-        }\r
-\r
-        // The CSS class (action, topic, notice, etc)\r
-        if (typeof message_obj.type !== "string") {\r
-            message_obj.type = '';\r
-        }\r
-\r
-        // Make sure we don't have NaN or something\r
-        if (typeof message_obj.msg !== "string") {\r
-            message_obj.msg = '';\r
-        }\r
-\r
-        // Update the scrollback\r
-        bs = this.get("scrollback");\r
-        bs.push(message_obj);\r
-\r
-        // Keep the scrolback limited\r
-        if (bs.length > 250) {\r
-            bs.splice(250);\r
-        }\r
-        this.set({"scrollback": bs}, {silent: true});\r
-\r
-        this.trigger("msg", message_obj);\r
-    },\r
-\r
-    closePanel: function () {\r
-        if (this.view) {\r
-            this.view.unbind();\r
-            this.view.remove();\r
-            this.view = undefined;\r
-            delete this.view;\r
-        }\r
-\r
-        var members = this.get('members');\r
-        if (members) {\r
-            members.reset([]);\r
-            this.unset('members');\r
-        }\r
-\r
-        kiwi.app.panels.remove(this);\r
-\r
-        this.unbind();\r
-        this.destroy();\r
-\r
-        // If closing the active panel, switch to the server panel\r
-        if (this.cid === kiwi.app.panels.active.cid) {\r
-            kiwi.app.panels.server.view.show();\r
-        }\r
-    },\r
-\r
-    // Alias to closePanel() for child objects to override\r
-    close: function () {\r
-        return this.closePanel();\r
-    },\r
-\r
-    isChannel: function () {\r
-        var channel_prefix = kiwi.gateway.get('channel_prefix'),\r
-            this_name = this.get('name');\r
-\r
-        if (this.isApplet() || !this_name) return false;\r
-        return (channel_prefix.indexOf(this_name[0]) > -1);\r
-    },\r
-\r
-    isApplet: function () {\r
-        return this.applet ? true : false;\r
-    },\r
-\r
-    isServer: function () {\r
-        return this.server ? true : false;\r
-    },\r
-\r
-    isActive: function () {\r
-        return (kiwi.app.panels.active === this);\r
-    }\r
-});
\ No newline at end of file
diff --git a/client/dev/model_panellist.js b/client/dev/model_panellist.js
deleted file mode 100644 (file)
index f16df71..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-kiwi.model.PanelList = Backbone.Collection.extend({\r
-    model: kiwi.model.Panel,\r
-\r
-    comparator: function (chan) {\r
-        return chan.get("name");\r
-    },\r
-    initialize: function () {\r
-        this.view = new kiwi.view.Tabs({"el": $('#tabs')[0], "model": this});\r
-\r
-        // Automatically create a server tab\r
-        this.add(new kiwi.model.Server({'name': kiwi.gateway.get('name')}));\r
-        this.server = this.getByName(kiwi.gateway.get('name'));\r
-\r
-        // Holds the active panel\r
-        this.active = null;\r
-\r
-        // Keep a tab on the active panel\r
-        this.bind('active', function (active_panel) {\r
-            this.active = active_panel;\r
-        }, this);\r
-\r
-    },\r
-    getByName: function (name) {\r
-        if (typeof name !== 'string') return;\r
-        return this.find(function (c) {\r
-            return name.toLowerCase() === c.get('name').toLowerCase();\r
-        });\r
-    }\r
-});
\ No newline at end of file
diff --git a/client/dev/model_server.js b/client/dev/model_server.js
deleted file mode 100644 (file)
index 55e567f..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-kiwi.model.Server = kiwi.model.Panel.extend({\r
-    // Used to determine if this is a server panel\r
-    server: true,\r
-\r
-    initialize: function (attributes) {\r
-        var name = "Server";\r
-        this.view = new kiwi.view.Panel({"model": this, "name": name});\r
-        this.set({\r
-            "scrollback": [],\r
-            "name": name\r
-        }, {"silent": true});\r
-\r
-        //this.addMsg(' ', '--> Kiwi IRC: Such an awesome IRC client', '', {style: 'color:#009900;'});\r
-\r
-        this.server_login = new kiwi.view.ServerSelect();\r
-        \r
-        this.view.$el.append(this.server_login.$el);\r
-        this.server_login.show();\r
-    }\r
-});
\ No newline at end of file
diff --git a/client/dev/utils.js b/client/dev/utils.js
deleted file mode 100644 (file)
index de64451..0000000
+++ /dev/null
@@ -1,760 +0,0 @@
-/*jslint devel: true, browser: true, continue: true, sloppy: true, forin: true, plusplus: true, maxerr: 50, indent: 4, nomen: true, regexp: true*/
-/*globals $, front, gateway, Utilityview */
-
-
-
-/**
-*   Suppresses console.log
-*   @param  {Boolean}   debug   Whether to re-enable console.log or not
-*/
-function manageDebug(debug) {
-    var log, consoleBackUp;
-    if (window.console) {
-        consoleBackUp = window.console.log;
-        window.console.log = function () {
-            if (debug) {
-                consoleBackUp.apply(console, arguments);
-            }
-        };
-    } else {
-        log = window.opera ? window.opera.postError : alert;
-        window.console = {};
-        window.console.log = function (str) {
-            if (debug) {
-                log(str);
-            }
-        };
-    }
-}
-
-/**
-*   Generate a random string of given length
-*   @param      {Number}    string_length   The length of the random string
-*   @returns    {String}                    The random string
-*/
-function randomString(string_length) {
-    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",
-        randomstring = '',
-        i,
-        rnum;
-    for (i = 0; i < string_length; i++) {
-        rnum = Math.floor(Math.random() * chars.length);
-        randomstring += chars.substring(rnum, rnum + 1);
-    }
-    return randomstring;
-}
-
-/**
-*   String.trim shim
-*/
-if (typeof String.prototype.trim === 'undefined') {
-    String.prototype.trim = function () {
-        return this.replace(/^\s+|\s+$/g, "");
-    };
-}
-
-/**
-*   String.lpad shim
-*   @param      {Number}    length      The length of padding
-*   @param      {String}    characher   The character to pad with
-*   @returns    {String}                The padded string
-*/
-if (typeof String.prototype.lpad === 'undefined') {
-    String.prototype.lpad = function (length, character) {
-        var padding = "",
-            i;
-        for (i = 0; i < length; i++) {
-            padding += character;
-        }
-        return (padding + this).slice(-length);
-    };
-}
-
-
-/**
-*   Convert seconds into hours:minutes:seconds
-*   @param      {Number}    secs    The number of seconds to converts
-*   @returns    {Object}            An object representing the hours/minutes/second conversion of secs
-*/
-function secondsToTime(secs) {
-    var hours, minutes, seconds, divisor_for_minutes, divisor_for_seconds, obj;
-    hours = Math.floor(secs / (60 * 60));
-
-    divisor_for_minutes = secs % (60 * 60);
-    minutes = Math.floor(divisor_for_minutes / 60);
-
-    divisor_for_seconds = divisor_for_minutes % 60;
-    seconds = Math.ceil(divisor_for_seconds);
-
-    obj = {
-        "h": hours,
-        "m": minutes,
-        "s": seconds
-    };
-    return obj;
-}
-
-
-
-
-
-
-/* Command input Alias + re-writing */
-function InputPreProcessor () {
-    this.recursive_depth = 3;
-
-    this.aliases = {};
-    this.vars = {version: 1};
-
-    // Current recursive depth
-    var depth = 0;
-
-
-    // Takes an array of words to process!
-    this.processInput = function (input) {
-        var words = input || [],
-            alias = this.aliases[words[0]],
-            alias_len,
-            current_alias_word = '',
-            compiled = [];
-
-        // If an alias wasn't found, return the original input
-        if (!alias) return input;
-
-        // Split the alias up into useable words
-        alias = alias.split(' ');
-        alias_len = alias.length;
-
-        // Iterate over each word and pop them into the final compiled array.
-        // Any $ words are processed with the result ending into the compiled array.
-        for (var i=0; i<alias_len; i++) {
-            current_alias_word = alias[i];
-
-            // Non $ word
-            if (current_alias_word[0] !== '$') {
-                compiled.push(current_alias_word);
-                continue;
-            }
-
-            // Refering to an input word ($N)
-            if (!isNaN(current_alias_word[1])) {
-                var num = current_alias_word.match(/\$(\d+)(\+)?(\d+)?/);
-
-                // Did we find anything or does the word it refers to non-existant?
-                if (!num || !words[num[1]]) continue;
-                
-                if (num[2] === '+' && num[3]) {
-                    // Add X number of words
-                    compiled = compiled.concat(words.slice(parseInt(num[1], 10), parseInt(num[1], 10) + parseInt(num[3], 10)));
-                } else if (num[2] === '+') {
-                    // Add the remaining of the words
-                    compiled = compiled.concat(words.slice(parseInt(num[1], 10)));
-                } else {
-                    // Add a single word
-                    compiled.push(words[parseInt(num[1], 10)]);
-                }
-
-                continue;
-            }
-
-
-            // Refering to a variable
-            if (typeof this.vars[current_alias_word.substr(1)] !== 'undefined') {
-
-                // Get the variable
-                compiled.push(this.vars[current_alias_word.substr(1)]);
-
-                continue;
-            }
-
-        }
-
-        return compiled;
-    };
-
-
-    this.process = function (input) {
-        input = input || '';
-
-        var words = input.split(' ');
-
-        depth++;
-        if (depth >= this.recursive_depth) {
-            depth--;
-            return input;
-        }
-
-        if (this.aliases[words[0]]) {
-            words = this.processInput(words);
-            
-            if (this.aliases[words[0]]) {
-                words = this.process(words.join(' ')).split(' ');
-            }
-
-        }
-
-        depth--;
-        return words.join(' ');
-    };
-}
-
-
-
-
-
-
-
-
-
-
-
-/**
- * Convert HSL to RGB formatted colour
- */
-function hsl2rgb(h, s, l) {
-    var m1, m2, hue;
-    var r, g, b
-    s /=100;
-    l /= 100;
-    if (s == 0)
-        r = g = b = (l * 255);
-    else {
-        function HueToRgb(m1, m2, hue) {
-            var v;
-            if (hue < 0)
-                hue += 1;
-            else if (hue > 1)
-                hue -= 1;
-
-            if (6 * hue < 1)
-                v = m1 + (m2 - m1) * hue * 6;
-            else if (2 * hue < 1)
-                v = m2;
-            else if (3 * hue < 2)
-                v = m1 + (m2 - m1) * (2/3 - hue) * 6;
-            else
-                v = m1;
-
-            return 255 * v;
-        }
-        if (l <= 0.5)
-            m2 = l * (s + 1);
-        else
-            m2 = l + s - l * s;
-        m1 = l * 2 - m2;
-        hue = h / 360;
-        r = HueToRgb(m1, m2, hue + 1/3);
-        g = HueToRgb(m1, m2, hue);
-        b = HueToRgb(m1, m2, hue - 1/3);
-    }
-    return [r,g,b];
-}
-
-
-
-
-
-/**
-*   Formats a message. Adds bold, underline and colouring
-*   @param      {String}    msg The message to format
-*   @returns    {String}        The HTML formatted message
-*/
-function formatIRCMsg (msg) {
-    var re, next;
-
-    if ((!msg) || (typeof msg !== 'string')) {
-        return '';
-    }
-
-    // bold
-    if (msg.indexOf(String.fromCharCode(2)) !== -1) {
-        next = '<b>';
-        while (msg.indexOf(String.fromCharCode(2)) !== -1) {
-            msg = msg.replace(String.fromCharCode(2), next);
-            next = (next === '<b>') ? '</b>' : '<b>';
-        }
-        if (next === '</b>') {
-            msg = msg + '</b>';
-        }
-    }
-
-    // underline
-    if (msg.indexOf(String.fromCharCode(31)) !== -1) {
-        next = '<u>';
-        while (msg.indexOf(String.fromCharCode(31)) !== -1) {
-            msg = msg.replace(String.fromCharCode(31), next);
-            next = (next === '<u>') ? '</u>' : '<u>';
-        }
-        if (next === '</u>') {
-            msg = msg + '</u>';
-        }
-    }
-
-    // colour
-    /**
-    *   @inner
-    */
-    msg = (function (msg) {
-        var replace, colourMatch, col, i, match, to, endCol, fg, bg, str;
-        replace = '';
-        /**
-        *   @inner
-        */
-        colourMatch = function (str) {
-            var re = /^\x03([0-9][0-5]?)(,([0-9][0-5]?))?/;
-            return re.exec(str);
-        };
-        /**
-        *   @inner
-        */
-        col = function (num) {
-            switch (parseInt(num, 10)) {
-            case 0:
-                return '#FFFFFF';
-            case 1:
-                return '#000000';
-            case 2:
-                return '#000080';
-            case 3:
-                return '#008000';
-            case 4:
-                return '#FF0000';
-            case 5:
-                return '#800040';
-            case 6:
-                return '#800080';
-            case 7:
-                return '#FF8040';
-            case 8:
-                return '#FFFF00';
-            case 9:
-                return '#80FF00';
-            case 10:
-                return '#008080';
-            case 11:
-                return '#00FFFF';
-            case 12:
-                return '#0000FF';
-            case 13:
-                return '#FF55FF';
-            case 14:
-                return '#808080';
-            case 15:
-                return '#C0C0C0';
-            default:
-                return null;
-            }
-        };
-        if (msg.indexOf('\x03') !== -1) {
-            i = msg.indexOf('\x03');
-            replace = msg.substr(0, i);
-            while (i < msg.length) {
-                /**
-                *   @inner
-                */
-                match = colourMatch(msg.substr(i, 6));
-                if (match) {
-                    //console.log(match);
-                    // Next colour code
-                    to = msg.indexOf('\x03', i + 1);
-                    endCol = msg.indexOf(String.fromCharCode(15), i + 1);
-                    if (endCol !== -1) {
-                        if (to === -1) {
-                            to = endCol;
-                        } else {
-                            to = ((to < endCol) ? to : endCol);
-                        }
-                    }
-                    if (to === -1) {
-                        to = msg.length;
-                    }
-                    //console.log(i, to);
-                    fg = col(match[1]);
-                    bg = col(match[3]);
-                    str = msg.substring(i + 1 + match[1].length + ((bg !== null) ? match[2].length + 1 : 0), to);
-                    //console.log(str);
-                    replace += '<span style="' + ((fg !== null) ? 'color: ' + fg + '; ' : '') + ((bg !== null) ? 'background-color: ' + bg + ';' : '') + '">' + str + '</span>';
-                    i = to;
-                } else {
-                    if ((msg[i] !== '\x03') && (msg[i] !== String.fromCharCode(15))) {
-                        replace += msg[i];
-                    }
-                    i++;
-                }
-            }
-            return replace;
-        }
-        return msg;
-    }(msg));
-    
-    return msg;
-}
-
-
-
-
-function formatDate (d) {
-    d = d || new Date();
-    return d.toLocaleDateString() + ', ' + d.getHours().toString() + ':' + d.getMinutes().toString() + ':' + d.getSeconds().toString();
-}
-
-
-
-
-
-
-
-
-/*
-    PLUGINS
-    Each function in each object is looped through and ran. The resulting text
-    is expected to be returned.
-*/
-var plugins = [
-    {
-        name: "images",
-        onaddmsg: function (event, opts) {
-            if (!event.msg) {
-                return event;
-            }
-
-            event.msg = event.msg.replace(/^((https?\:\/\/|ftp\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?(\.jpg|\.jpeg|\.gif|\.bmp|\.png)$/gi, function (url) {
-                // Don't let any future plugins change it (ie. html_safe plugins)
-                event.event_bubbles = false;
-
-                var img = '<img class="link_img_a" src="' + url + '" height="100%" width="100%" />';
-                return '<a class="link_ext link_img" target="_blank" rel="nofollow" href="' + url + '" style="height:50px;width:50px;display:block">' + img + '<div class="tt box"></div></a>';
-            });
-
-            return event;
-        }
-    },
-
-    {
-        name: "html_safe",
-        onaddmsg: function (event, opts) {
-            event.msg = $('<div/>').text(event.msg).html();
-            event.nick = $('<div/>').text(event.nick).html();
-
-            return event;
-        }
-    },
-
-    {
-        name: "activity",
-        onaddmsg: function (event, opts) {
-            //if (kiwi.front.cur_channel.name.toLowerCase() !== kiwi.front.tabviews[event.tabview.toLowerCase()].name) {
-            //    kiwi.front.tabviews[event.tabview].activity();
-            //}
-
-            return event;
-        }
-    },
-
-    {
-        name: "highlight",
-        onaddmsg: function (event, opts) {
-            //var tab = Tabviews.getTab(event.tabview.toLowerCase());
-
-            // If we have a highlight...
-            //if (event.msg.toLowerCase().indexOf(kiwi.gateway.nick.toLowerCase()) > -1) {
-            //    if (Tabview.getCurrentTab() !== tab) {
-            //        tab.highlight();
-            //    }
-            //    if (kiwi.front.isChannel(tab.name)) {
-            //        event.msg = '<span style="color:red;">' + event.msg + '</span>';
-            //    }
-            //}
-
-            // If it's a PM, highlight
-            //if (!kiwi.front.isChannel(tab.name) && tab.name !== "server"
-            //    && Tabview.getCurrentTab().name.toLowerCase() !== tab.name
-            //) {
-            //    tab.highlight();
-            //}
-
-            return event;
-        }
-    },
-
-
-
-    {
-        //Following method taken from: http://snipplr.com/view/13533/convert-text-urls-into-links/
-        name: "linkify_plain",
-        onaddmsg: function (event, opts) {
-            if (!event.msg) {
-                return event;
-            }
-
-            event.msg = event.msg.replace(/((https?\:\/\/|ftp\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi, function (url) {
-                var nice;
-                // If it's any of the supported images in the images plugin, skip it
-                if (url.match(/(\.jpg|\.jpeg|\.gif|\.bmp|\.png)$/)) {
-                    return url;
-                }
-
-                nice = url;
-                if (url.match('^https?:\/\/')) {
-                    //nice = nice.replace(/^https?:\/\//i,'')
-                    nice = url; // Shutting up JSLint...
-                } else {
-                    url = 'http://' + url;
-                }
-
-                //return '<a class="link_ext" target="_blank" rel="nofollow" href="' + url + '">' + nice + '<div class="tt box"></div></a>';
-                return '<a class="link_ext" target="_blank" rel="nofollow" href="' + url + '">' + nice + '</a>';
-            });
-
-            return event;
-        }
-    },
-
-    {
-        name: "lftobr",
-        onaddmsg: function (event, opts) {
-            if (!event.msg) {
-                return event;
-            }
-
-            event.msg = event.msg.replace(/\n/gi, function (txt) {
-                return '<br/>';
-            });
-
-            return event;
-        }
-    },
-
-
-    /*
-     * Disabled due to many websites closing kiwi with iframe busting
-    {
-        name: "inBrowser",
-        oninit: function (event, opts) {
-            $('#windows a.link_ext').live('mouseover', this.mouseover);
-            $('#windows a.link_ext').live('mouseout', this.mouseout);
-            $('#windows a.link_ext').live('click', this.mouseclick);
-        },
-
-        onunload: function (event, opts) {
-            // TODO: make this work (remove all .link_ext_browser as created in mouseover())
-            $('#windows a.link_ext').die('mouseover', this.mouseover);
-            $('#windows a.link_ext').die('mouseout', this.mouseout);
-            $('#windows a.link_ext').die('click', this.mouseclick);
-        },
-
-
-
-        mouseover: function (e) {
-            var a = $(this),
-                tt = $('.tt', a),
-                tooltip;
-
-            if (tt.text() === '') {
-                tooltip = $('<a class="link_ext_browser">Open in Kiwi..</a>');
-                tt.append(tooltip);
-            }
-
-            tt.css('top', -tt.outerHeight() + 'px');
-            tt.css('left', (a.outerWidth() / 2) - (tt.outerWidth() / 2));
-        },
-
-        mouseout: function (e) {
-            var a = $(this),
-                tt = $('.tt', a);
-        },
-
-        mouseclick: function (e) {
-            var a = $(this),
-                t;
-
-            switch (e.target.className) {
-            case 'link_ext':
-            case 'link_img_a':
-                return true;
-                //break;
-            case 'link_ext_browser':
-                t = new Utilityview('Browser');
-                t.topic = a.attr('href');
-
-                t.iframe = $('<iframe border="0" class="utility_view" src="" style="width:100%;height:100%;border:none;"></iframe>');
-                t.iframe.attr('src', a.attr('href'));
-                t.div.append(t.iframe);
-                t.show();
-                break;
-            }
-            return false;
-
-        }
-    },
-    */
-
-    {
-        name: "nick_colour",
-        onaddmsg: function (event, opts) {
-            if (!event.msg) {
-                return event;
-            }
-
-            //if (typeof kiwi.front.tabviews[event.tabview].nick_colours === 'undefined') {
-            //    kiwi.front.tabviews[event.tabview].nick_colours = {};
-            //}
-
-            //if (typeof kiwi.front.tabviews[event.tabview].nick_colours[event.nick] === 'undefined') {
-            //    kiwi.front.tabviews[event.tabview].nick_colours[event.nick] = this.randColour();
-            //}
-
-            //var c = kiwi.front.tabviews[event.tabview].nick_colours[event.nick];
-            var c = this.randColour();
-            event.nick = '<span style="color:' + c + ';">' + event.nick + '</span>';
-
-            return event;
-        },
-
-
-
-        randColour: function () {
-            var h = this.rand(-250, 0),
-                s = this.rand(30, 100),
-                l = this.rand(20, 70);
-            return 'hsl(' + h + ',' + s + '%,' + l + '%)';
-        },
-
-
-        rand: function (min, max) {
-            return parseInt(Math.random() * (max - min + 1), 10) + min;
-        }
-    },
-
-    {
-        name: "kiwitest",
-        oninit: function (event, opts) {
-            console.log('registering namespace');
-            $(gateway).bind("kiwi.lol.browser", function (e, data) {
-                console.log('YAY kiwitest');
-                console.log(data);
-            });
-        }
-    }
-];
-
-
-
-
-
-
-
-/**
-*   @namespace
-*/
-kiwi.plugs = {};
-/**
-*   Loaded plugins
-*/
-kiwi.plugs.loaded = {};
-/**
-*   Load a plugin
-*   @param      {Object}    plugin  The plugin to be loaded
-*   @returns    {Boolean}           True on success, false on failure
-*/
-kiwi.plugs.loadPlugin = function (plugin) {
-    var plugin_ret;
-    if (typeof plugin.name !== 'string') {
-        return false;
-    }
-
-    plugin_ret = kiwi.plugs.run('plugin_load', {plugin: plugin});
-    if (typeof plugin_ret === 'object') {
-        kiwi.plugs.loaded[plugin_ret.plugin.name] = plugin_ret.plugin;
-        kiwi.plugs.loaded[plugin_ret.plugin.name].local_data = new kiwi.dataStore('kiwi_plugin_' + plugin_ret.plugin.name);
-    }
-    kiwi.plugs.run('init', {}, {run_only: plugin_ret.plugin.name});
-
-    return true;
-};
-
-/**
-*   Unload a plugin
-*   @param  {String}    plugin_name The name of the plugin to unload
-*/
-kiwi.plugs.unloadPlugin = function (plugin_name) {
-    if (typeof kiwi.plugs.loaded[plugin_name] !== 'object') {
-        return;
-    }
-
-    kiwi.plugs.run('unload', {}, {run_only: plugin_name});
-    delete kiwi.plugs.loaded[plugin_name];
-};
-
-
-
-/**
-*   Run an event against all loaded plugins
-*   @param      {String}    event_name  The name of the event
-*   @param      {Object}    event_data  The data to pass to the plugin
-*   @param      {Object}    opts        Options
-*   @returns    {Object}                Event data, possibly modified by the plugins
-*/
-kiwi.plugs.run = function (event_name, event_data, opts) {
-    var ret = event_data,
-        ret_tmp,
-        plugin_name;
-
-    // Set some defaults if not provided
-    event_data = (typeof event_data === 'undefined') ? {} : event_data;
-    opts = (typeof opts === 'undefined') ? {} : opts;
-
-    for (plugin_name in kiwi.plugs.loaded) {
-        // If we're only calling 1 plugin, make sure it's that one
-        if (typeof opts.run_only === 'string' && opts.run_only !== plugin_name) {
-            continue;
-        }
-
-        if (typeof kiwi.plugs.loaded[plugin_name]['on' + event_name] === 'function') {
-            try {
-                ret_tmp = kiwi.plugs.loaded[plugin_name]['on' + event_name](ret, opts);
-                if (ret_tmp === null) {
-                    return null;
-                }
-                ret = ret_tmp;
-
-                if (typeof ret.event_bubbles === 'boolean' && ret.event_bubbles === false) {
-                    delete ret.event_bubbles;
-                    return ret;
-                }
-            } catch (e) {
-            }
-        }
-    }
-
-    return ret;
-};
-
-
-
-/**
-*   @constructor
-*   @param  {String}    data_namespace  The namespace for the data store
-*/
-kiwi.dataStore = function (data_namespace) {
-    var namespace = data_namespace;
-
-    this.get = function (key) {
-        return $.jStorage.get(data_namespace + '_' + key);
-    };
-
-    this.set = function (key, value) {
-        return $.jStorage.set(data_namespace + '_' + key, value);
-    };
-};
-
-kiwi.data = new kiwi.dataStore('kiwi');
-
-
-
-
-/*
- * jQuery jStorage plugin 
- * https://github.com/andris9/jStorage/
- */
-(function(f){if(!f||!(f.toJSON||Object.toJSON||window.JSON)){throw new Error("jQuery, MooTools or Prototype needs to be loaded before jStorage!")}var g={},d={jStorage:"{}"},h=null,j=0,l=f.toJSON||Object.toJSON||(window.JSON&&(JSON.encode||JSON.stringify)),e=f.evalJSON||(window.JSON&&(JSON.decode||JSON.parse))||function(m){return String(m).evalJSON()},i=false;_XMLService={isXML:function(n){var m=(n?n.ownerDocument||n:0).documentElement;return m?m.nodeName!=="HTML":false},encode:function(n){if(!this.isXML(n)){return false}try{return new XMLSerializer().serializeToString(n)}catch(m){try{return n.xml}catch(o){}}return false},decode:function(n){var m=("DOMParser" in window&&(new DOMParser()).parseFromString)||(window.ActiveXObject&&function(p){var q=new ActiveXObject("Microsoft.XMLDOM");q.async="false";q.loadXML(p);return q}),o;if(!m){return false}o=m.call("DOMParser" in window&&(new DOMParser())||window,n,"text/xml");return this.isXML(o)?o:false}};function k(){if("localStorage" in window){try{if(window.localStorage){d=window.localStorage;i="localStorage"}}catch(p){}}else{if("globalStorage" in window){try{if(window.globalStorage){d=window.globalStorage[window.location.hostname];i="globalStorage"}}catch(o){}}else{h=document.createElement("link");if(h.addBehavior){h.style.behavior="url(#default#userData)";document.getElementsByTagName("head")[0].appendChild(h);h.load("jStorage");var n="{}";try{n=h.getAttribute("jStorage")}catch(m){}d.jStorage=n;i="userDataBehavior"}else{h=null;return}}}b()}function b(){if(d.jStorage){try{g=e(String(d.jStorage))}catch(m){d.jStorage="{}"}}else{d.jStorage="{}"}j=d.jStorage?String(d.jStorage).length:0}function c(){try{d.jStorage=l(g);if(h){h.setAttribute("jStorage",d.jStorage);h.save("jStorage")}j=d.jStorage?String(d.jStorage).length:0}catch(m){}}function a(m){if(!m||(typeof m!="string"&&typeof m!="number")){throw new TypeError("Key name must be string or numeric")}return true}f.jStorage={version:"0.1.5.1",set:function(m,n){a(m);if(_XMLService.isXML(n)){n={_is_xml:true,xml:_XMLService.encode(n)}}g[m]=n;c();return n},get:function(m,n){a(m);if(m in g){if(g[m]&&typeof g[m]=="object"&&g[m]._is_xml&&g[m]._is_xml){return _XMLService.decode(g[m].xml)}else{return g[m]}}return typeof(n)=="undefined"?null:n},deleteKey:function(m){a(m);if(m in g){delete g[m];c();return true}return false},flush:function(){g={};c();return true},storageObj:function(){function m(){}m.prototype=g;return new m()},index:function(){var m=[],n;for(n in g){if(g.hasOwnProperty(n)){m.push(n)}}return m},storageSize:function(){return j},currentBackend:function(){return i},storageAvailable:function(){return !!i},reInit:function(){var m,o;if(h&&h.addBehavior){m=document.createElement("link");h.parentNode.replaceChild(m,h);h=m;h.style.behavior="url(#default#userData)";document.getElementsByTagName("head")[0].appendChild(h);h.load("jStorage");o="{}";try{o=h.getAttribute("jStorage")}catch(n){}d.jStorage=o;i="userDataBehavior"}b()}};k()})(window.jQuery||window.$);
\ No newline at end of file
diff --git a/client/dev/view.js b/client/dev/view.js
deleted file mode 100644 (file)
index 8e10785..0000000
+++ /dev/null
@@ -1,1020 +0,0 @@
-/*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.MemberList = Backbone.View.extend({\r
-    tagName: "ul",\r
-    events: {\r
-        "click .nick": "nickClick"\r
-    },\r
-    initialize: function (options) {\r
-        this.model.bind('all', this.render, this);\r
-        $(this.el).appendTo('#memberlists');\r
-    },\r
-    render: function () {\r
-        var $this = $(this.el);\r
-        $this.empty();\r
-        this.model.forEach(function (member) {\r
-            $('<li><a class="nick"><span class="prefix">' + member.get("prefix") + '</span>' + member.get("nick") + '</a></li>')\r
-                .appendTo($this)\r
-                .data('member', member);\r
-        });\r
-    },\r
-    nickClick: function (x) {\r
-        var target = $(x.currentTarget).parent('li'),\r
-            member = target.data('member'),\r
-            userbox = new kiwi.view.UserBox();\r
-        \r
-        userbox.member = member;\r
-        $('.userbox', this.$el).remove();\r
-        target.append(userbox.$el);\r
-    },\r
-    show: function () {\r
-        $('#memberlists').children().removeClass('active');\r
-        $(this.el).addClass('active');\r
-    }\r
-});\r
-\r
-\r
-\r
-kiwi.view.UserBox = Backbone.View.extend({\r
-    events: {\r
-        'click .query': 'queryClick',\r
-        'click .info': 'infoClick'\r
-    },\r
-\r
-    initialize: function () {\r
-        this.$el = $($('#tmpl_userbox').html());\r
-    },\r
-\r
-    queryClick: function (event) {\r
-        var panel = new kiwi.model.Channel({name: this.member.get('nick')});\r
-        kiwi.app.panels.add(panel);\r
-        panel.view.show();\r
-    },\r
-\r
-    infoClick: function (event) {\r
-        kiwi.gateway.raw('WHOIS ' + this.member.get('nick'));\r
-    }\r
-});\r
-\r
-kiwi.view.NickChangeBox = Backbone.View.extend({\r
-    events: {\r
-        'submit': 'changeNick',\r
-        'click .cancel': 'close'\r
-    },\r
-    \r
-    initialize: function () {\r
-        this.$el = $($('#tmpl_nickchange').html());\r
-    },\r
-    \r
-    render: function () {\r
-        // Add the UI component and give it focus\r
-        kiwi.app.controlbox.$el.prepend(this.$el);\r
-        this.$el.find('input').focus();\r
-\r
-        this.$el.css('bottom', kiwi.app.controlbox.$el.outerHeight(true));\r
-    },\r
-    \r
-    close: function () {\r
-        this.$el.remove();\r
-\r
-    },\r
-\r
-    changeNick: function (event) {\r
-        var that = this;\r
-        kiwi.gateway.changeNick(this.$el.find('input').val(), function (err, val) {\r
-            that.close();\r
-        });\r
-        return false;\r
-    }\r
-});\r
-\r
-kiwi.view.ServerSelect = function () {\r
-    // Are currently showing all the controlls or just a nick_change box?\r
-    var state = 'all';\r
-\r
-    var model = Backbone.View.extend({\r
-        events: {\r
-            'submit form': 'submitForm',\r
-            'click .show_more': 'showMore'\r
-        },\r
-\r
-        initialize: function () {\r
-            this.$el = $($('#tmpl_server_select').html());\r
-\r
-            kiwi.gateway.bind('onconnect', this.networkConnected, this);\r
-            kiwi.gateway.bind('connecting', this.networkConnecting, this);\r
-\r
-            kiwi.gateway.bind('onirc_error', function (data) {\r
-                $('button', this.$el).attr('disabled', null);\r
-\r
-                if (data.error == 'nickname_in_use') {\r
-                    this.setStatus('Nickname already taken');\r
-                    this.show('nick_change');\r
-                }\r
-            }, this);\r
-        },\r
-\r
-        submitForm: function (event) {\r
-            if (state === 'nick_change') {\r
-                this.submitNickChange(event);\r
-            } else {\r
-                this.submitLogin(event);\r
-            }\r
-\r
-            $('button', this.$el).attr('disabled', 1);\r
-            return false;\r
-        },\r
-\r
-        submitLogin: function (event) {\r
-            // If submitting is disabled, don't do anything\r
-            if ($('button', this.$el).attr('disabled')) return;\r
-            \r
-            var values = {\r
-                nick: $('.nick', this.$el).val(),\r
-                server: $('.server', this.$el).val(),\r
-                port: $('.port', this.$el).val(),\r
-                ssl: $('.ssl', this.$el).prop('checked'),\r
-                password: $('.password', this.$el).val(),\r
-                channel: $('.channel', this.$el).val()\r
-            };\r
-\r
-            this.trigger('server_connect', values);\r
-        },\r
-\r
-        submitNickChange: function (event) {\r
-            kiwi.gateway.changeNick($('.nick', this.$el).val());\r
-            this.networkConnecting();\r
-        },\r
-\r
-        showMore: function (event) {\r
-            $('.more', this.$el).slideDown('fast');\r
-            $('.server', this.$el).select();\r
-        },\r
-\r
-        populateFields: function (defaults) {\r
-            var nick, server, channel;\r
-\r
-            defaults = defaults || {};\r
-\r
-            nick = defaults.nick || '';\r
-            server = defaults.server || '';\r
-            port = defaults.port || 6667;\r
-            ssl = defaults.ssl || 0;\r
-            password = defaults.password || '';\r
-            channel = defaults.channel || '';\r
-\r
-            $('.nick', this.$el).val(nick);\r
-            $('.server', this.$el).val(server);\r
-            $('.port', this.$el).val(port);\r
-            $('.ssl', this.$el).prop('checked', ssl);\r
-            $('.password', this.$el).val(password);\r
-            $('.channel', this.$el).val(channel);\r
-        },\r
-\r
-        hide: function () {\r
-            this.$el.slideUp();\r
-        },\r
-\r
-        show: function (new_state) {\r
-            new_state = new_state || 'all';\r
-\r
-            this.$el.show();\r
-\r
-            if (new_state === 'all') {\r
-                $('.show_more', this.$el).show();\r
-\r
-            } else if (new_state === 'more') {\r
-                $('.more', this.$el).slideDown('fast');\r
-\r
-            } else if (new_state === 'nick_change') {\r
-                $('.more', this.$el).hide();\r
-                $('.show_more', this.$el).hide();\r
-            }\r
-\r
-            state = new_state;\r
-        },\r
-\r
-        setStatus: function (text, class_name) {\r
-            $('.status', this.$el)\r
-                .text(text)\r
-                .attr('class', 'status')\r
-                .addClass(class_name)\r
-                .show();\r
-        },\r
-        clearStatus: function () {\r
-            $('.status', this.$el).hide();\r
-        },\r
-\r
-        networkConnected: function (event) {\r
-            this.setStatus('Connected :)', 'ok');\r
-            $('form', this.$el).hide();\r
-        },\r
-\r
-        networkConnecting: function (event) {\r
-            this.setStatus('Connecting..', 'ok');\r
-        },\r
-\r
-        showError: function (event) {\r
-            this.setStatus('Error connecting', 'error');\r
-            $('button', this.$el).attr('disabled', null);\r
-            this.show();\r
-        }\r
-    });\r
-\r
-\r
-    return new model(arguments);\r
-};\r
-\r
-\r
-kiwi.view.Panel = Backbone.View.extend({\r
-    tagName: "div",\r
-    className: "messages",\r
-    events: {\r
-        "click .chan": "chanClick"\r
-    },\r
-\r
-    initialize: function (options) {\r
-        this.initializePanel(options);\r
-    },\r
-\r
-    initializePanel: function (options) {\r
-        this.$el.css('display', 'none');\r
-        options = options || {};\r
-\r
-        // Containing element for this panel\r
-        if (options.container) {\r
-            this.$container = $(options.container);\r
-        } else {\r
-            this.$container = $('#panels .container1');\r
-        }\r
-\r
-        this.$el.appendTo(this.$container);\r
-\r
-        this.alert_level = 0;\r
-\r
-        this.model.bind('msg', this.newMsg, this);\r
-        this.msg_count = 0;\r
-\r
-        this.model.set({"view": this}, {"silent": true});\r
-    },\r
-\r
-    render: function () {\r
-        this.$el.empty();\r
-        this.model.get("backscroll").forEach(this.newMsg);\r
-    },\r
-    newMsg: function (msg) {\r
-        // TODO: make sure that the message pane is scrolled to the bottom (Or do we? ~Darren)\r
-        var re, line_msg, $this = this.$el,\r
-            nick_colour_hex;\r
-\r
-        // Escape any HTML that may be in here\r
-        msg.msg =  $('<div />').text(msg.msg).html();\r
-\r
-        // Make the channels clickable\r
-        re = new RegExp('\\B([' + kiwi.gateway.get('channel_prefix') + '][^ ,.\\007]+)', 'g');\r
-        msg.msg = msg.msg.replace(re, function (match) {\r
-            return '<a class="chan">' + match + '</a>';\r
-        });\r
-\r
-\r
-        // Make links clickable\r
-        msg.msg = msg.msg.replace(/((https?\:\/\/|ftp\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]*))?/gi, function (url) {\r
-            var nice;\r
-\r
-            // Add the http is no protoocol was found\r
-            if (url.match(/^www\./)) {\r
-                url = 'http://' + url;\r
-            }\r
-\r
-            nice = url;\r
-            if (nice.length > 100) {\r
-                nice = nice.substr(0, 100) + '...';\r
-            }\r
-\r
-            return '<a class="link_ext" target="_blank" rel="nofollow" href="' + url + '">' + nice + '</a>';\r
-        });\r
-\r
-\r
-        // Convert IRC formatting into HTML formatting\r
-        msg.msg = formatIRCMsg(msg.msg);\r
-\r
-\r
-        // Add some colours to the nick (Method based on IRSSIs nickcolor.pl)\r
-        nick_colour_hex = (function (nick) {\r
-            var nick_int = 0, rgb;\r
-\r
-            _.map(nick.split(''), function (i) { nick_int += i.charCodeAt(0); });\r
-            rgb = hsl2rgb(nick_int % 255, 70, 35);\r
-            rgb = rgb[2] | (rgb[1] << 8) | (rgb[0] << 16);\r
-\r
-            return '#' + rgb.toString(16);\r
-        })(msg.nick);\r
-\r
-        msg.nick_style = 'color:' + nick_colour_hex + ';';\r
-\r
-        // Build up and add the line\r
-        line_msg = '<div class="msg <%= type %>"><div class="time"><%- time %></div><div class="nick" style="<%= nick_style %>"><%- nick %></div><div class="text" style="<%= style %>"><%= msg %> </div></div>';\r
-        $this.append(_.template(line_msg, msg));\r
-\r
-        // Activity/alerts based on the type of new message\r
-        if (msg.type.match(/^action /)) {\r
-            this.alert('action');\r
-        } else if (msg.msg.indexOf(kiwi.gateway.get('nick')) > -1) {\r
-            kiwi.app.view.alertWindow('* People are talking!');\r
-            this.alert('highlight');\r
-        } else {\r
-            // If this is the active panel, send an alert out\r
-            if (this.model.isActive()) {\r
-                kiwi.app.view.alertWindow('* People are talking!');\r
-            }\r
-            this.alert('activity');\r
-        }\r
-\r
-        this.scrollToBottom();\r
-\r
-        // Make sure our DOM isn't getting too large (Acts as scrollback)\r
-        this.msg_count++;\r
-        if (this.msg_count > 250) {\r
-            $('.msg:first', this.$el).remove();\r
-            this.msg_count--;\r
-        }\r
-    },\r
-    chanClick: function (x) {\r
-        kiwi.gateway.join($(x.srcElement).text());\r
-    },\r
-    show: function () {\r
-        var $this = this.$el;\r
-\r
-        // Hide all other panels and show this one\r
-        this.$container.children().css('display', 'none');\r
-        $this.css('display', 'block');\r
-\r
-        // Show this panels memberlist\r
-        var members = this.model.get("members");\r
-        if (members) {\r
-            $('#memberlists').show();\r
-            members.view.show();\r
-        } else {\r
-            // Memberlist not found for this panel, hide any active ones\r
-            $('#memberlists').hide().children().removeClass('active');\r
-        }\r
-\r
-        kiwi.app.view.doLayout();\r
-\r
-        this.scrollToBottom();\r
-        this.alert('none');\r
-\r
-        this.trigger('active', this.model);\r
-        kiwi.app.panels.trigger('active', this.model);\r
-    },\r
-\r
-\r
-    alert: function (level) {\r
-        // No need to highlight if this si the active panel\r
-        if (this.model == kiwi.app.panels.active) return;\r
-\r
-        var types, type_idx;\r
-        types = ['none', 'action', 'activity', 'highlight'];\r
-\r
-        // Default alert level\r
-        level = level || 'none';\r
-\r
-        // If this alert level does not exist, assume clearing current level\r
-        type_idx = _.indexOf(types, level);\r
-        if (!type_idx) {\r
-            level = 'none';\r
-            type_idx = 0;\r
-        }\r
-\r
-        // Only 'upgrade' the alert. Never down (unless clearing)\r
-        if (type_idx !== 0 && type_idx <= this.alert_level) {\r
-            return;\r
-        }\r
-\r
-        // Clear any existing levels\r
-        this.model.tab.removeClass(function (i, css) {\r
-            return (css.match(/\balert_\S+/g) || []).join(' ');\r
-        });\r
-\r
-        // Add the new level if there is one\r
-        if (level !== 'none') {\r
-            this.model.tab.addClass('alert_' + level);\r
-        }\r
-\r
-        this.alert_level = type_idx;\r
-    },\r
-\r
-\r
-    // Scroll to the bottom of the panel\r
-    scrollToBottom: function () {\r
-        // TODO: Don't scroll down if we're scrolled up the panel a little\r
-        this.$container[0].scrollTop = this.$container[0].scrollHeight;\r
-    }\r
-});\r
-\r
-kiwi.view.Applet = kiwi.view.Panel.extend({\r
-    className: 'applet',\r
-    initialize: function (options) {\r
-        this.initializePanel(options);\r
-    }\r
-});\r
-\r
-kiwi.view.Channel = kiwi.view.Panel.extend({\r
-    initialize: function (options) {\r
-        this.initializePanel(options);\r
-        this.model.bind('change:topic', this.topic, this);\r
-    },\r
-\r
-    topic: function (topic) {\r
-        if (typeof topic !== 'string' || !topic) {\r
-            topic = this.model.get("topic");\r
-        }\r
-        \r
-        this.model.addMsg('', '== Topic for ' + this.model.get('name') + ' is: ' + topic, 'topic');\r
-\r
-        // If this is the active channel then update the topic bar\r
-        if (kiwi.app.panels.active === this) {\r
-            kiwi.app.topicbar.setCurrentTopic(this.model.get("topic"));\r
-        }\r
-    }\r
-});\r
-\r
-// Model for this = kiwi.model.PanelList\r
-kiwi.view.Tabs = Backbone.View.extend({\r
-    events: {\r
-        'click li': 'tabClick',\r
-        'click li img': 'partClick'\r
-    },\r
-\r
-    initialize: function () {\r
-        this.model.on("add", this.panelAdded, this);\r
-        this.model.on("remove", this.panelRemoved, this);\r
-        this.model.on("reset", this.render, this);\r
-\r
-        this.model.on('active', this.panelActive, this);\r
-\r
-        this.tabs_applets = $('ul.applets', this.$el);\r
-        this.tabs_msg = $('ul.channels', this.$el);\r
-\r
-        kiwi.gateway.on('change:name', function (gateway, new_val) {\r
-            $('span', this.model.server.tab).text(new_val);\r
-        }, this);\r
-    },\r
-    render: function () {\r
-        var that = this;\r
-\r
-        this.tabs_msg.empty();\r
-        \r
-        // Add the server tab first\r
-        this.model.server.tab\r
-            .data('panel_id', this.model.server.cid)\r
-            .appendTo(this.tabs_msg);\r
-\r
-        // Go through each panel adding its tab\r
-        this.model.forEach(function (panel) {\r
-            // If this is the server panel, ignore as it's already added\r
-            if (panel == that.model.server) return;\r
-\r
-            panel.tab\r
-                .data('panel_id', panel.cid)\r
-                .appendTo(panel.isApplet() ? this.tabs_applets : this.tabs_msg);\r
-        });\r
-\r
-        kiwi.app.view.doLayout();\r
-    },\r
-\r
-    updateTabTitle: function (panel, new_title) {\r
-        $('span', panel.tab).text(new_title);\r
-    },\r
-\r
-    panelAdded: function (panel) {\r
-        // Add a tab to the panel\r
-        panel.tab = $('<li><span>' + (panel.get('title') || panel.get('name')) + '</span></li>');\r
-\r
-        if (panel.isServer()) {\r
-            panel.tab.addClass('server');\r
-        }\r
-\r
-        panel.tab.data('panel_id', panel.cid)\r
-            .appendTo(panel.isApplet() ? this.tabs_applets : this.tabs_msg);\r
-\r
-        panel.bind('change:title', this.updateTabTitle);\r
-        kiwi.app.view.doLayout();\r
-    },\r
-    panelRemoved: function (panel) {\r
-        panel.tab.remove();\r
-        delete panel.tab;\r
-\r
-        kiwi.app.view.doLayout();\r
-    },\r
-\r
-    panelActive: function (panel) {\r
-        // Remove any existing tabs or part images\r
-        $('img', this.$el).remove();\r
-        this.tabs_applets.children().removeClass('active');\r
-        this.tabs_msg.children().removeClass('active');\r
-\r
-        panel.tab.addClass('active');\r
-\r
-        // Only show the part image on non-server tabs\r
-        if (!panel.isServer()) {\r
-            panel.tab.append('<img src="img/redcross.png" />');\r
-        }\r
-    },\r
-\r
-    tabClick: function (e) {\r
-        var tab = $(e.currentTarget);\r
-\r
-        var panel = this.model.getByCid(tab.data('panel_id'));\r
-        if (!panel) {\r
-            // A panel wasn't found for this tab... wadda fuck\r
-            return;\r
-        }\r
-\r
-        panel.view.show();\r
-    },\r
-\r
-    partClick: function (e) {\r
-        var tab = $(e.currentTarget).parent();\r
-        var panel = this.model.getByCid(tab.data('panel_id'));\r
-\r
-        // Only need to part if it's a channel\r
-        // If the nicklist is empty, we haven't joined the channel as yet\r
-        if (panel.isChannel() && panel.get('members').models.length > 0) {\r
-            kiwi.gateway.part(panel.get('name'));\r
-        } else {\r
-            panel.close();\r
-        }\r
-    },\r
-\r
-    next: function () {\r
-        var next = kiwi.app.panels.active.tab.next();\r
-        if (!next.length) next = $('li:first', this.tabs_msgs);\r
-\r
-        next.click();\r
-    },\r
-    prev: function () {\r
-        var prev = kiwi.app.panels.active.tab.prev();\r
-        if (!prev.length) prev = $('li:last', this.tabs_msgs);\r
-\r
-        prev.click();\r
-    }\r
-});\r
-\r
-\r
-\r
-kiwi.view.TopicBar = Backbone.View.extend({\r
-    events: {\r
-        'keydown input': 'process'\r
-    },\r
-\r
-    initialize: function () {\r
-        kiwi.app.panels.bind('active', function (active_panel) {\r
-            this.setCurrentTopic(active_panel.get('topic'));\r
-        }, this);\r
-    },\r
-\r
-    process: function (ev) {\r
-        var inp = $(ev.currentTarget),\r
-            inp_val = inp.val();\r
-\r
-        if (ev.keyCode !== 13) return;\r
-\r
-        if (kiwi.app.panels.active.isChannel()) {\r
-            kiwi.gateway.topic(kiwi.app.panels.active.get('name'), inp_val);\r
-        }\r
-    },\r
-\r
-    setCurrentTopic: function (new_topic) {\r
-        new_topic = new_topic || '';\r
-\r
-        // We only want a plain text version\r
-        new_topic = $('<div>').html(formatIRCMsg(new_topic));\r
-        $('input', this.$el).val(new_topic.text());\r
-    }\r
-});\r
-\r
-\r
-\r
-kiwi.view.ControlBox = Backbone.View.extend({\r
-    events: {\r
-        'keydown input.inp': 'process',\r
-        'click .nick': 'showNickChange'\r
-    },\r
-\r
-    initialize: function () {\r
-        var that = this;\r
-\r
-        this.buffer = [];  // Stores previously run commands\r
-        this.buffer_pos = 0;  // The current position in the buffer\r
-\r
-        this.preprocessor = new InputPreProcessor();\r
-        this.preprocessor.recursive_depth = 5;\r
-\r
-        // Hold tab autocomplete data\r
-        this.tabcomplete = {active: false, data: [], prefix: ''};\r
-\r
-        kiwi.gateway.bind('change:nick', function () {\r
-            $('.nick', that.$el).text(this.get('nick'));\r
-        });\r
-    },\r
-\r
-    showNickChange: function (ev) {\r
-        (new kiwi.view.NickChangeBox()).render();\r
-    },\r
-\r
-    process: function (ev) {\r
-        var that = this,\r
-            inp = $(ev.currentTarget),\r
-            inp_val = inp.val(),\r
-            meta;\r
-\r
-        if (navigator.appVersion.indexOf("Mac") !== -1) {\r
-            meta = ev.ctrlKey;\r
-        } else {\r
-            meta = ev.altKey;\r
-        }\r
-\r
-        // If not a tab key, reset the tabcomplete data\r
-        if (this.tabcomplete.active && ev.keyCode !== 9) {\r
-            this.tabcomplete.active = false;\r
-            this.tabcomplete.data = [];\r
-            this.tabcomplete.prefix = '';\r
-        }\r
-        \r
-        switch (true) {\r
-        case (ev.keyCode === 13):              // return\r
-            inp_val = inp_val.trim();\r
-\r
-            if (inp_val) {\r
-                this.processInput(inp.val());\r
-\r
-                this.buffer.push(inp.val());\r
-                this.buffer_pos = this.buffer.length;\r
-            }\r
-\r
-            inp.val('');\r
-\r
-            break;\r
-\r
-        case (ev.keyCode === 38):              // up\r
-            if (this.buffer_pos > 0) {\r
-                this.buffer_pos--;\r
-                inp.val(this.buffer[this.buffer_pos]);\r
-            }\r
-            break;\r
-\r
-        case (ev.keyCode === 40):              // down\r
-            if (this.buffer_pos < this.buffer.length) {\r
-                this.buffer_pos++;\r
-                inp.val(this.buffer[this.buffer_pos]);\r
-            }\r
-            break;\r
-\r
-        case (ev.keyCode === 37 && meta):            // left\r
-            kiwi.app.panels.view.prev();\r
-            return false;\r
-\r
-        case (ev.keyCode === 39 && meta):            // right\r
-            kiwi.app.panels.view.next();\r
-            return false;\r
-\r
-        case (ev.keyCode === 9):                     // tab\r
-            this.tabcomplete.active = true;\r
-            if (_.isEqual(this.tabcomplete.data, [])) {\r
-                // Get possible autocompletions\r
-                var ac_data = [];\r
-                $.each(kiwi.app.panels.active.get('members').models, function (i, member) {\r
-                    if (!member) return;\r
-                    ac_data.push(member.get('nick'));\r
-                });\r
-                ac_data = _.sortBy(ac_data, function (nick) {\r
-                    return nick;\r
-                });\r
-                this.tabcomplete.data = ac_data;\r
-            }\r
-\r
-            if (inp_val[inp[0].selectionStart - 1] === ' ') {\r
-                return false;\r
-            }\r
-            \r
-            (function () {\r
-                var tokens = inp_val.substring(0, inp[0].selectionStart).split(' '),\r
-                    val,\r
-                    p1,\r
-                    newnick,\r
-                    range,\r
-                    nick = tokens[tokens.length - 1];\r
-                if (this.tabcomplete.prefix === '') {\r
-                    this.tabcomplete.prefix = nick;\r
-                }\r
-\r
-                this.tabcomplete.data = _.select(this.tabcomplete.data, function (n) {\r
-                    return (n.toLowerCase().indexOf(that.tabcomplete.prefix.toLowerCase()) === 0);\r
-                });\r
-\r
-                if (this.tabcomplete.data.length > 0) {\r
-                    p1 = inp[0].selectionStart - (nick.length);\r
-                    val = inp_val.substr(0, p1);\r
-                    newnick = this.tabcomplete.data.shift();\r
-                    this.tabcomplete.data.push(newnick);\r
-                    val += newnick;\r
-                    val += inp_val.substr(inp[0].selectionStart);\r
-                    inp.val(val);\r
-\r
-                    if (inp[0].setSelectionRange) {\r
-                        inp[0].setSelectionRange(p1 + newnick.length, p1 + newnick.length);\r
-                    } else if (inp[0].createTextRange) { // not sure if this bit is actually needed....\r
-                        range = inp[0].createTextRange();\r
-                        range.collapse(true);\r
-                        range.moveEnd('character', p1 + newnick.length);\r
-                        range.moveStart('character', p1 + newnick.length);\r
-                        range.select();\r
-                    }\r
-                }\r
-            }).apply(this);\r
-            return false;\r
-        }\r
-    },\r
-\r
-\r
-    processInput: function (command_raw) {\r
-        var command, params,\r
-            pre_processed;\r
-        \r
-        // The default command\r
-        if (command_raw[0] !== '/') {\r
-            command_raw = '/msg ' + kiwi.app.panels.active.get('name') + ' ' + command_raw;\r
-        }\r
-\r
-        // Process the raw command for any aliases\r
-        this.preprocessor.vars.server = kiwi.gateway.get('name');\r
-        this.preprocessor.vars.channel = kiwi.app.panels.active.get('name');\r
-        this.preprocessor.vars.destination = this.preprocessor.vars.channel;\r
-        command_raw = this.preprocessor.process(command_raw);\r
-\r
-        // Extract the command and parameters\r
-        params = command_raw.split(' ');\r
-        if (params[0][0] === '/') {\r
-            command = params[0].substr(1).toLowerCase();\r
-            params = params.splice(1);\r
-        } else {\r
-            // Default command\r
-            command = 'msg';\r
-            params.unshift(kiwi.app.panels.active.get('name'));\r
-        }\r
-\r
-        // Trigger the command events\r
-        this.trigger('command', {command: command, params: params});\r
-        this.trigger('command_' + command, {command: command, params: params});\r
-\r
-        // If we didn't have any listeners for this event, fire a special case\r
-        // TODO: This feels dirty. Should this really be done..?\r
-        if (!this._callbacks['command_' + command]) {\r
-            this.trigger('unknown_command', {command: command, params: params});\r
-        }\r
-    }\r
-});\r
-\r
-\r
-\r
-\r
-kiwi.view.StatusMessage = Backbone.View.extend({\r
-    initialize: function () {\r
-        this.$el.hide();\r
-\r
-        // Timer for hiding the message after X seconds\r
-        this.tmr = null;\r
-    },\r
-\r
-    text: function (text, opt) {\r
-        // Defaults\r
-        opt = opt || {};\r
-        opt.type = opt.type || '';\r
-        opt.timeout = opt.timeout || 5000;\r
-\r
-        this.$el.text(text).attr('class', opt.type);\r
-        this.$el.slideDown(kiwi.app.view.doLayout);\r
-\r
-        if (opt.timeout) this.doTimeout(opt.timeout);\r
-    },\r
-\r
-    html: function (html, opt) {\r
-        // Defaults\r
-        opt = opt || {};\r
-        opt.type = opt.type || '';\r
-        opt.timeout = opt.timeout || 5000;\r
-\r
-        this.$el.html(text).attr('class', opt.type);\r
-        this.$el.slideDown(kiwi.app.view.doLayout);\r
-\r
-        if (opt.timeout) this.doTimeout(opt.timeout);\r
-    },\r
-\r
-    hide: function () {\r
-        this.$el.slideUp(kiwi.app.view.doLayout);\r
-    },\r
-\r
-    doTimeout: function (length) {\r
-        if (this.tmr) clearTimeout(this.tmr);\r
-        var that = this;\r
-        this.tmr = setTimeout(function () { that.hide(); }, length);\r
-    }\r
-});\r
-\r
-\r
-\r
-\r
-kiwi.view.ResizeHandler = Backbone.View.extend({\r
-    events: {\r
-        'mousedown': 'startDrag',\r
-        'mouseup': 'stopDrag'\r
-    },\r
-\r
-    initialize: function () {\r
-        this.dragging = false;\r
-        this.starting_width = {};\r
-\r
-        $(window).on('mousemove', $.proxy(this.onDrag, this));\r
-    },\r
-\r
-    startDrag: function (event) {\r
-        this.dragging = true;\r
-    },\r
-\r
-    stopDrag: function (event) {\r
-        this.dragging = false;\r
-    },\r
-\r
-    onDrag: function (event) {\r
-        if (!this.dragging) return;\r
-\r
-        this.$el.css('left', event.clientX - (this.$el.outerWidth(true) / 2));\r
-        $('#memberlists').css('width', this.$el.parent().width() - (this.$el.position().left + this.$el.outerWidth()));\r
-        kiwi.app.view.doLayout();\r
-    }\r
-});\r
-\r
-\r
-\r
-kiwi.view.Application = Backbone.View.extend({\r
-    initialize: function () {\r
-        $(window).resize(this.doLayout);\r
-        $('#toolbar').resize(this.doLayout);\r
-        $('#controlbox').resize(this.doLayout);\r
-\r
-        this.doLayout();\r
-\r
-        $(document).keydown(this.setKeyFocus);\r
-\r
-        // Confirmation require to leave the page\r
-        window.onbeforeunload = function () {\r
-            if (kiwi.gateway.isConnected()) {\r
-                return 'This will close all KiwiIRC conversations. Are you sure you want to close this window?';\r
-            }\r
-        };\r
-    },\r
-\r
-\r
-    // Globally shift focus to the command input box on a keypress\r
-    setKeyFocus: function (ev) {\r
-        // If we're copying text, don't shift focus\r
-        if (ev.ctrlKey || ev.altKey) {\r
-            return;\r
-        }\r
-\r
-        // If we're typing into an input box somewhere, ignore\r
-        if (ev.target.tagName.toLowerCase() === 'input') {\r
-            return;\r
-        }\r
-\r
-        $('#controlbox .inp').focus();\r
-    },\r
-\r
-\r
-    doLayout: function () {\r
-        var el_panels = $('#panels');\r
-        var el_memberlists = $('#memberlists');\r
-        var el_toolbar = $('#toolbar');\r
-        var el_controlbox = $('#controlbox');\r
-        var el_resize_handle = $('#memberlists_resize_handle');\r
-\r
-        var css_heights = {\r
-            top: el_toolbar.outerHeight(true),\r
-            bottom: el_controlbox.outerHeight(true)\r
-        };\r
-\r
-        el_panels.css(css_heights);\r
-        el_memberlists.css(css_heights);\r
-        el_resize_handle.css(css_heights);\r
-\r
-        if (el_memberlists.css('display') != 'none') {\r
-            // Handle + panels to the side of the memberlist\r
-            el_panels.css('right', el_memberlists.outerWidth(true) + el_resize_handle.outerWidth(true));\r
-            el_resize_handle.css('left', el_memberlists.position().left - el_resize_handle.outerWidth(true));\r
-        } else {\r
-            // Memberlist is hidden so handle + panels to the right edge\r
-            el_panels.css('right', el_resize_handle.outerWidth(true));\r
-            el_resize_handle.css('left', el_panels.outerWidth(true));\r
-        }\r
-    },\r
-\r
-\r
-    alertWindow: function (title) {\r
-        if (!this.alertWindowTimer) {\r
-            this.alertWindowTimer = new (function () {\r
-                var that = this;\r
-                var tmr;\r
-                var has_focus = true;\r
-                var state = 0;\r
-                var default_title = 'Kiwi IRC';\r
-                var title = 'Kiwi IRC';\r
-\r
-                this.setTitle = function (new_title) {\r
-                    new_title = new_title || default_title;\r
-                    window.document.title = new_title;\r
-                    return new_title;\r
-                };\r
-\r
-                this.start = function (new_title) {\r
-                    // Don't alert if we already have focus\r
-                    if (has_focus) return;\r
-\r
-                    title = new_title;\r
-                    if (tmr) return;\r
-                    tmr = setInterval(this.update, 1000);\r
-                };\r
-\r
-                this.stop = function () {\r
-                    // Stop the timer and clear the title\r
-                    if (tmr) clearInterval(tmr);\r
-                    tmr = null;\r
-                    this.setTitle();\r
-\r
-                    // Some browsers don't always update the last title correctly\r
-                    // Wait a few seconds and then reset\r
-                    setTimeout(this.reset, 2000);\r
-                };\r
-\r
-                this.reset = function () {\r
-                    if (tmr) return;\r
-                    that.setTitle();\r
-                };\r
-\r
-\r
-                this.update = function () {\r
-                    if (state === 0) {\r
-                        that.setTitle(title);\r
-                        state = 1;\r
-                    } else {\r
-                        that.setTitle();\r
-                        state = 0;\r
-                    }\r
-                };\r
-\r
-                $(window).focus(function (event) {\r
-                    has_focus = true;\r
-                    that.stop();\r
-\r
-                    // Some browsers don't always update the last title correctly\r
-                    // Wait a few seconds and then reset\r
-                    setTimeout(this.reset, 2000);\r
-                });\r
-\r
-                $(window).blur(function (event) {\r
-                    has_focus = false;\r
-                });\r
-            })();\r
-        }\r
-\r
-        this.alertWindowTimer.start(title);\r
-    },\r
-\r
-\r
-    barsHide: function (instant) {\r
-        var that = this;\r
-\r
-        if (!instant) {\r
-            $('#toolbar').slideUp({queue: false, duration: 400, step: this.doLayout});\r
-            $('#controlbox').slideUp({queue: false, duration: 400, step: this.doLayout});\r
-        } else {\r
-            $('#toolbar').slideUp(0);\r
-            $('#controlbox').slideUp(0);\r
-            this.doLayout();\r
-        }\r
-    },\r
-\r
-    barsShow: function (instant) {\r
-        var that = this;\r
-\r
-        if (!instant) {\r
-            $('#toolbar').slideDown({queue: false, duration: 400, step: this.doLayout});\r
-            $('#controlbox').slideDown({queue: false, duration: 400, step: this.doLayout});\r
-        } else {\r
-            $('#toolbar').slideDown(0);\r
-            $('#controlbox').slideDown(0);\r
-            this.doLayout();\r
-        }\r
-    }\r
-});
\ No newline at end of file