Remove a use of jquery that was causing some ugly.

This commit is contained in:
Ian Gulliver
2014-05-16 18:00:11 +03:00
parent fe7bab189d
commit f8089fb7a1

View File

@@ -63,8 +63,9 @@ Cosmopolite.prototype.shutdown = function() {
this.socket_ = null; this.socket_ = null;
socket.close(); socket.close();
} }
if (this.$) { if (this.messageHandler_) {
this.$('window').off('message'); window.removeEventListener('message', this.messageHandler_);
this.messageHandler_ = null;
} }
}; };
@@ -212,15 +213,15 @@ Cosmopolite.prototype.onReceiveMessage_ = function(data) {
* messages are normal. * messages are normal.
*/ */
Cosmopolite.prototype.registerMessageHandlers_ = function() { Cosmopolite.prototype.registerMessageHandlers_ = function() {
this.$(window).on('message', this.$.proxy(function(e) { this.messageHandler_ = function(e) {
if (e.originalEvent.origin != window.location.origin) { if (e.origin != window.location.origin) {
console.log( console.log('cosmopolite: received message from bad origin:', e.origin);
'cosmopolite: received message from bad origin:', e.originalEvent.origin);
return; return;
} }
console.log('cosmopolite: received browser message:', e.originalEvent.data); console.log('cosmopolite: received browser message:', e.data);
this.onReceiveMessage_(e.originalEvent.data); this.onReceiveMessage_(e.data);
}, this)); }.bind(this);
window.addEventListener('message', this.messageHandler_);
}; };
/** /**