From: Darren Date: Thu, 13 Sep 2012 16:50:38 +0000 (+0100) Subject: IE hacks; Script loader X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c4fc06f6d34df77820bb4f85748383bd6a810be3;p=KiwiIRC.git IE hacks; Script loader --- diff --git a/client_backbone/dev/model_application.js b/client_backbone/dev/model_application.js index c01749f..2f23856 100644 --- a/client_backbone/dev/model_application.js +++ b/client_backbone/dev/model_application.js @@ -21,9 +21,9 @@ kiwi.model.Application = Backbone.Model.extend(new (function () { this.start = function () { // Only debug if set in the querystring if (!getQueryVariable('debug')) { - manageDebug(false); + //manageDebug(false); } else { - manageDebug(true); + //manageDebug(true); } // Set the gateway up @@ -35,23 +35,29 @@ kiwi.model.Application = Backbone.Model.extend(new (function () { this.panels.server.server_login.bind('server_connect', function (event) { var server_login = this; - server_login.networkConnecting(); - - // Attempt to load the transport scripts from the kiwi_server - loadScript(that.kiwi_server + '/socket.io/socket.io.js', function () { - auto_connect_details = event; + auto_connect_details = event; + server_login.networkConnecting(); + + $script(that.kiwi_server + '/socket.io/socket.io.js?ts='+(new Date().getTime()), function () { + if (!window.io) { + kiwiServerNotFound(); + return; + } + kiwi.gateway.set('kiwi_server', that.kiwi_server + '/kiwi'); kiwi.gateway.set('nick', event.nick); kiwi.gateway.connect(event.server, 6667, false, false, function () {}); - }, function (error) { - console.log('Failed to load transport scripts from Kiwi server', error); - server_login.showError(); }); }); }; + function kiwiServerNotFound (e) { + that.panels.server.server_login.showError(); + } + + this.detectKiwiServer = function () { // If running from file, default to localhost:7777 by default if (window.location.protocol === 'file') { @@ -63,7 +69,7 @@ kiwi.model.Application = Backbone.Model.extend(new (function () { 'https' : 'http'; - this.kiwi_server = proto + '://' + window.location.host + ':' + window.location.port; + this.kiwi_server = proto + '://' + window.location.host + ':' + (window.location.port || '80'); } }; diff --git a/client_backbone/dev/model_gateway.js b/client_backbone/dev/model_gateway.js index 242491f..d19147c 100644 --- a/client_backbone/dev/model_gateway.js +++ b/client_backbone/dev/model_gateway.js @@ -144,7 +144,7 @@ kiwi.model.Gateway = Backbone.Model.extend(new (function () { * Parses the response from the server */ this.parse = function (item) { - console.log('gateway event', item); + //console.log('gateway event', item); if (item.event !== undefined) { that.trigger('on' + item.event, item); diff --git a/client_backbone/dev/model_member.js b/client_backbone/dev/model_member.js index e74fd05..535f906 100644 --- a/client_backbone/dev/model_member.js +++ b/client_backbone/dev/model_member.js @@ -50,7 +50,7 @@ kiwi.model.Member = Backbone.Model.extend({ modes = this.get("modes"); modes = _.reject(modes, function (m) { - return (modes_to_remove.indexOf(m) !== -1); + return (_.indexOf(modes_to_remove, m) !== -1); }); this.set({"prefix": this.getPrefix(modes), "modes": modes}); diff --git a/client_backbone/dev/view.js b/client_backbone/dev/view.js index 9865204..0edc446 100644 --- a/client_backbone/dev/view.js +++ b/client_backbone/dev/view.js @@ -217,7 +217,7 @@ kiwi.view.Panel = Backbone.View.extend({ nick_colour_hex = (function (nick) { var nick_int = 0, rgb; - nick.split('').map(function (i) { nick_int += i.charCodeAt(0); }); + _.map(nick.split(''), function (i) { nick_int += i.charCodeAt(0); }); rgb = hsl2rgb(nick_int % 255, 70, 35); rgb = rgb[2] | (rgb[1] << 8) | (rgb[0] << 16); diff --git a/client_backbone/index.html b/client_backbone/index.html index a05c776..547ad30 100644 --- a/client_backbone/index.html +++ b/client_backbone/index.html @@ -1,3 +1,4 @@ + @@ -61,15 +62,13 @@ +