Timeslider autoupdate on pad change

pull/661/head
Egil Moeller 2012-04-23 13:29:27 +02:00
parent 583743a3f9
commit 1faae5b756
3 changed files with 53 additions and 53 deletions

View File

@ -467,32 +467,30 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
revisionInfo.addChangeset(astart, aend, forwardcs, backwardcs, data.timeDeltas[i]); revisionInfo.addChangeset(astart, aend, forwardcs, backwardcs, data.timeDeltas[i]);
} }
if (callback) callback(start - 1, start + data.forwardsChangesets.length * granularity - 1); if (callback) callback(start - 1, start + data.forwardsChangesets.length * granularity - 1);
} },
}; handleMessageFromServer: function (obj)
function handleMessageFromServer()
{ {
debugLog("handleMessage:", arguments); debugLog("handleMessage:", arguments);
var obj = arguments[0]['data'];
var expectedType = "COLLABROOM";
obj = JSON.parse(obj); if (obj.type == "COLLABROOM")
if (obj['type'] == expectedType)
{ {
obj = obj['data']; obj = obj.data;
if (obj['type'] == "NEW_CHANGES") if (obj.type == "NEW_CHANGES")
{ {
debugLog(obj); debugLog(obj);
var changeset = Changeset.moveOpsToNewPool( var changeset = Changeset.moveOpsToNewPool(
obj.changeset, (new AttribPool()).fromJsonable(obj.apool), padContents.apool); obj.changeset, (new AttribPool()).fromJsonable(obj.apool), padContents.apool);
var changesetBack = Changeset.inverse(
obj.changeset, padContents.currentLines, padContents.alines, padContents.apool);
var changesetBack = Changeset.moveOpsToNewPool( var changesetBack = Changeset.moveOpsToNewPool(
obj.changesetBack, (new AttribPool()).fromJsonable(obj.apool), padContents.apool); changesetBack, (new AttribPool()).fromJsonable(obj.apool), padContents.apool);
loadedNewChangeset(changeset, changesetBack, obj.newRev - 1, obj.timeDelta); loadedNewChangeset(changeset, changesetBack, obj.newRev - 1, obj.timeDelta);
} }
else if (obj['type'] == "NEW_AUTHORDATA") else if (obj.type == "NEW_AUTHORDATA")
{ {
var authorMap = {}; var authorMap = {};
authorMap[obj.author] = obj.data; authorMap[obj.author] = obj.data;
@ -504,17 +502,22 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
BroadcastSlider.setAuthors(authors); BroadcastSlider.setAuthors(authors);
} }
else if (obj['type'] == "NEW_SAVEDREV") else if (obj.type == "NEW_SAVEDREV")
{ {
var savedRev = obj.savedRev; var savedRev = obj.savedRev;
BroadcastSlider.addSavedRevision(savedRev.revNum, savedRev); BroadcastSlider.addSavedRevision(savedRev.revNum, savedRev);
} }
} }
else if(obj.type == "CHANGESET_REQ")
{
changesetLoader.handleSocketResponse(obj);
}
else else
{ {
debugLog("incorrect message type: " + obj['type'] + ", expected " + expectedType); debugLog("Unknown message type: " + obj.type);
} }
} }
};
function handleSocketClosed(params) function handleSocketClosed(params)
{ {

View File

@ -360,6 +360,8 @@ function handshake()
//this message advices the client to disconnect //this message advices the client to disconnect
if (obj.disconnect) if (obj.disconnect)
{ {
console.warn("FORCED TO DISCONNECT");
console.warn(obj);
padconnectionstatus.disconnected(obj.disconnect); padconnectionstatus.disconnected(obj.disconnect);
socket.disconnect(); socket.disconnect();
return; return;

View File

@ -80,16 +80,11 @@ function init() {
{ {
handleClientVars(message); handleClientVars(message);
} }
else if(message.type == "CHANGESET_REQ")
{
changesetLoader.handleSocketResponse(message);
}
else if(message.accessStatus) else if(message.accessStatus)
{ {
$("body").html("<h2>You have no permission to access this pad</h2>") $("body").html("<h2>You have no permission to access this pad</h2>")
} else { } else {
console.warn("Unknown message type: " + message.type); changesetLoader.handleMessageFromServer(message);
console.warn(["XXX", message]);
} }
}); });