Switch to Array.forEach() where possible.
This commit is contained in:
@@ -23,17 +23,17 @@ cosmopolite.Client = function(opt_callbacks, opt_urlPrefix, opt_namespace) {
|
|||||||
|
|
||||||
this.stateCache_ = {};
|
this.stateCache_ = {};
|
||||||
|
|
||||||
var scripts = [
|
var scriptUrls = [
|
||||||
'https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js',
|
'https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js',
|
||||||
'/_ah/channel/jsapi',
|
'/_ah/channel/jsapi',
|
||||||
];
|
];
|
||||||
this.numScriptsToLoad_ = scripts.length;
|
this.numScriptsToLoad_ = scriptUrls.length;
|
||||||
for (var i = 0; i < scripts.length; i++) {
|
scriptUrls.forEach(function(scriptUrl) {
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.src = scripts[i];
|
script.src = scriptUrl;
|
||||||
script.onload = this.onLoad_.bind(this);
|
script.onload = this.onLoad_.bind(this);
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
}
|
}, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
cosmopolite.Client.prototype.onLoad_ = function() {
|
cosmopolite.Client.prototype.onLoad_ = function() {
|
||||||
@@ -170,9 +170,7 @@ cosmopolite.Client.prototype.onCreateChannel_ = function(data) {
|
|||||||
});
|
});
|
||||||
// Handle messages that were immediately available as if they came over the
|
// Handle messages that were immediately available as if they came over the
|
||||||
// channel.
|
// channel.
|
||||||
for (var i = 0; i < data['messages'].length; ++i) {
|
data['messages'].forEach(this.onServerMessage_, this);
|
||||||
this.onServerMessage_(data['messages'][i]);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
cosmopolite.Client.prototype.onSocketOpen_ = function() {
|
cosmopolite.Client.prototype.onSocketOpen_ = function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user