map / forEach use native impl, if available. ace2_common extends the prototype of Array, if not

This commit is contained in:
Matthias Bartelmeß 2012-03-13 21:10:10 +01:00
parent cccd8a923c
commit b28bfe8e31
4 changed files with 44 additions and 60 deletions

View file

@ -28,9 +28,6 @@ var linestylefilter = require('./linestylefilter').linestylefilter;
var colorutils = require('./colorutils').colorutils;
var Ace2Common = require('./ace2_common');
var map = Ace2Common.map;
var forEach = Ace2Common.forEach;
// These parameters were global, now they are injected. A reference to the
// Timeslider controller would probably be more appropriate.
function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider)
@ -155,7 +152,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
// splice the lines
splice: function(start, numRemoved, newLinesVA)
{
var newLines = map(Array.prototype.slice.call(arguments, 2), function(s) {
var newLines = Array.prototype.slice.call(arguments, 2).map(function(s) {
return s;
});
@ -278,7 +275,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
debugLog('Time Delta: ', timeDelta)
updateTimer();
var authors = map(padContents.getActiveAuthors(), function(name)
var authors = padContents.getActiveAuthors().map(function(name)
{
return authorData[name];
});
@ -384,7 +381,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
changesetLoader.queueUp(start, 1, update);
}
var authors = map(padContents.getActiveAuthors(), function(name){
var authors = padContents.getActiveAuthors().map(function(name){
return authorData[name];
});
BroadcastSlider.setAuthors(authors);
@ -527,7 +524,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
authorMap[obj.author] = obj.data;
receiveAuthorData(authorMap);
var authors = map(padContents.getActiveAuthors(),function(name) {
var authors = padContents.getActiveAuthors().map(function(name) {
return authorData[name];
});
@ -607,10 +604,13 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
setChannelState("DISCONNECTED", reason);
}
/// Since its not used, import 'forEach' has been dropped
/*window['onloadFuncts'] = [];
window.onload = function ()
{
window['isloaded'] = true;
forEach(window['onloadFuncts'],function (funct)
{
funct();