mirror of
				https://github.com/ether/etherpad-lite.git
				synced 2025-11-04 02:01:30 +01:00 
			
		
		
		
	Timeslider autoupdate on pad change
This commit is contained in:
		
							parent
							
								
									583743a3f9
								
							
						
					
					
						commit
						1faae5b756
					
				@ -467,55 +467,58 @@ 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)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      debugLog("handleMessage:", arguments);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (obj.type == "COLLABROOM")
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        obj = obj.data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (obj.type == "NEW_CHANGES")
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          debugLog(obj);
 | 
				
			||||||
 | 
					          var changeset = Changeset.moveOpsToNewPool(
 | 
				
			||||||
 | 
					            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(
 | 
				
			||||||
 | 
					            changesetBack, (new AttribPool()).fromJsonable(obj.apool), padContents.apool);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          loadedNewChangeset(changeset, changesetBack, obj.newRev - 1, obj.timeDelta);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (obj.type == "NEW_AUTHORDATA")
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          var authorMap = {};
 | 
				
			||||||
 | 
					          authorMap[obj.author] = obj.data;
 | 
				
			||||||
 | 
					          receiveAuthorData(authorMap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          var authors = _.map(padContents.getActiveAuthors(), function(name) {
 | 
				
			||||||
 | 
					            return authorData[name];
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          BroadcastSlider.setAuthors(authors);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (obj.type == "NEW_SAVEDREV")
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          var savedRev = obj.savedRev;
 | 
				
			||||||
 | 
					          BroadcastSlider.addSavedRevision(savedRev.revNum, savedRev);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      else if(obj.type == "CHANGESET_REQ")
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        changesetLoader.handleSocketResponse(obj);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        debugLog("Unknown message type: " + obj.type);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function handleMessageFromServer()
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    debugLog("handleMessage:", arguments);
 | 
					 | 
				
			||||||
    var obj = arguments[0]['data'];
 | 
					 | 
				
			||||||
    var expectedType = "COLLABROOM";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    obj = JSON.parse(obj);
 | 
					 | 
				
			||||||
    if (obj['type'] == expectedType)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      obj = obj['data'];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      if (obj['type'] == "NEW_CHANGES")
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        debugLog(obj);
 | 
					 | 
				
			||||||
        var changeset = Changeset.moveOpsToNewPool(
 | 
					 | 
				
			||||||
        obj.changeset, (new AttribPool()).fromJsonable(obj.apool), padContents.apool);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        var changesetBack = Changeset.moveOpsToNewPool(
 | 
					 | 
				
			||||||
        obj.changesetBack, (new AttribPool()).fromJsonable(obj.apool), padContents.apool);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        loadedNewChangeset(changeset, changesetBack, obj.newRev - 1, obj.timeDelta);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      else if (obj['type'] == "NEW_AUTHORDATA")
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        var authorMap = {};
 | 
					 | 
				
			||||||
        authorMap[obj.author] = obj.data;
 | 
					 | 
				
			||||||
        receiveAuthorData(authorMap);
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        var authors = _.map(padContents.getActiveAuthors(), function(name) {
 | 
					 | 
				
			||||||
          return authorData[name];
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        BroadcastSlider.setAuthors(authors);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      else if (obj['type'] == "NEW_SAVEDREV")
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        var savedRev = obj.savedRev;
 | 
					 | 
				
			||||||
        BroadcastSlider.addSavedRevision(savedRev.revNum, savedRev);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      debugLog("incorrect message type: " + obj['type'] + ", expected " + expectedType);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  function handleSocketClosed(params)
 | 
					  function handleSocketClosed(params)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    debugLog("socket closed!", params);
 | 
					    debugLog("socket closed!", params);
 | 
				
			||||||
 | 
				
			|||||||
@ -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;
 | 
				
			||||||
 | 
				
			|||||||
@ -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]);
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user