use shared functions from Ace2Common
parent
9ede14a546
commit
465f6c2de7
|
@ -26,47 +26,16 @@ var AttribPool = require('/AttributePoolFactory').createAttributePool;
|
|||
var Changeset = require('/Changeset');
|
||||
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)
|
||||
{
|
||||
var changesetLoader = undefined;
|
||||
// just in case... (todo: this must be somewhere else in the client code.)
|
||||
// Below Array#map code was direct pasted by AppJet/Etherpad, licence unknown. Possible source: http://www.tutorialspoint.com/javascript/array_map.htm
|
||||
if (!Array.prototype.map)
|
||||
{
|
||||
Array.prototype.map = function(fun /*, thisp*/ )
|
||||
{
|
||||
var len = this.length >>> 0;
|
||||
if (typeof fun != "function") throw new TypeError();
|
||||
|
||||
var res = new Array(len);
|
||||
var thisp = arguments[1];
|
||||
for (var i = 0; i < len; i++)
|
||||
{
|
||||
if (i in this) res[i] = fun.call(thisp, this[i], i, this);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
}
|
||||
|
||||
// Below Array#forEach code was direct pasted by AppJet/Etherpad, licence unknown. Possible source: http://www.tutorialspoint.com/javascript/array_foreach.htm
|
||||
if (!Array.prototype.forEach)
|
||||
{
|
||||
Array.prototype.forEach = function(fun /*, thisp*/ )
|
||||
{
|
||||
var len = this.length >>> 0;
|
||||
if (typeof fun != "function") throw new TypeError();
|
||||
|
||||
var thisp = arguments[1];
|
||||
for (var i = 0; i < len; i++)
|
||||
{
|
||||
if (i in this) fun.call(thisp, this[i], i, this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Below Array#indexOf code was direct pasted by AppJet/Etherpad, licence unknown. Possible source: http://www.tutorialspoint.com/javascript/array_indexof.htm
|
||||
if (!Array.prototype.indexOf)
|
||||
|
@ -191,10 +160,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
|
|||
// splice the lines
|
||||
splice: function(start, numRemoved, newLinesVA)
|
||||
{
|
||||
var newLines = Array.prototype.slice.call(arguments, 2).map(
|
||||
|
||||
function(s)
|
||||
{
|
||||
var newLines = map(Array.prototype.slice.call(arguments, 2), function(s) {
|
||||
return s;
|
||||
});
|
||||
|
||||
|
@ -316,10 +282,13 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
|
|||
padContents.currentTime += timeDelta * 1000;
|
||||
debugLog('Time Delta: ', timeDelta)
|
||||
updateTimer();
|
||||
BroadcastSlider.setAuthors(padContents.getActiveAuthors().map(function(name)
|
||||
|
||||
var authors = map(padContents.getActiveAuthors(), function(name)
|
||||
{
|
||||
return authorData[name];
|
||||
}));
|
||||
});
|
||||
|
||||
BroadcastSlider.setAuthors(authors);
|
||||
}
|
||||
|
||||
function updateTimer()
|
||||
|
@ -419,10 +388,11 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
|
|||
|
||||
changesetLoader.queueUp(start, 1, update);
|
||||
}
|
||||
BroadcastSlider.setAuthors(padContents.getActiveAuthors().map(function(name)
|
||||
{
|
||||
|
||||
var authors = map(padContents.getActiveAuthors(), function(name){
|
||||
return authorData[name];
|
||||
}));
|
||||
});
|
||||
BroadcastSlider.setAuthors(authors);
|
||||
}
|
||||
|
||||
changesetLoader = {
|
||||
|
@ -561,10 +531,12 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
|
|||
var authorMap = {};
|
||||
authorMap[obj.author] = obj.data;
|
||||
receiveAuthorData(authorMap);
|
||||
BroadcastSlider.setAuthors(padContents.getActiveAuthors().map(function(name)
|
||||
{
|
||||
|
||||
var authors = map(padContents.getActiveAuthors(),function(name) {
|
||||
return authorData[name];
|
||||
}));
|
||||
});
|
||||
|
||||
BroadcastSlider.setAuthors(authors);
|
||||
}
|
||||
else if (obj['type'] == "NEW_SAVEDREV")
|
||||
{
|
||||
|
@ -691,7 +663,7 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
|
|||
window.onload = function ()
|
||||
{
|
||||
window['isloaded'] = true;
|
||||
window['onloadFuncts'].forEach(function (funct)
|
||||
forEach(window['onloadFuncts'],function (funct)
|
||||
{
|
||||
funct();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue