diff options
author | John McLear <john@mclear.co.uk> | 2013-04-07 18:40:55 +0100 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2013-04-07 18:40:55 +0100 |
commit | 12a2da2884895fa7e1afb25b5e1384d53af20730 (patch) | |
tree | e79f9da462c0c87c7426ef8645c3f340e552bb96 /src/static/js/changesettracker.js | |
parent | 85c68b1f5157c9ccb81593ee2ca3b1dc0806eb66 (diff) | |
download | etherpad-lite-12a2da2884895fa7e1afb25b5e1384d53af20730.zip |
attempting to get right client authorid sent with changeset
Diffstat (limited to 'src/static/js/changesettracker.js')
-rw-r--r-- | src/static/js/changesettracker.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/static/js/changesettracker.js b/src/static/js/changesettracker.js index 58ef21cb..e641cff7 100644 --- a/src/static/js/changesettracker.js +++ b/src/static/js/changesettracker.js @@ -26,6 +26,8 @@ var Changeset = require('./Changeset'); function makeChangesetTracker(scheduler, apool, aceCallbacksProvider) { +//console.log("CS", Changeset); + // latest official text from server var baseAText = Changeset.makeAText("\n"); // changes applied to baseText that have been submitted @@ -161,6 +163,40 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider) } else { + // Get my authorID + var authorId = parent.parent.pad.myUserInfo.userId; + // Rewrite apool authors with my author information + + // We need to replace apool numToAttrib array where first value is author + // With thisSession.author + var numToAttr = apool.numToAttrib; + if(numToAttr){ + for (var attr in numToAttr){ + if (numToAttr[attr][0] === 'author'){ + // We force write the author over a change, for sanity n stuff + apool.numToAttrib[attr][1] = authorId; + } + } + } + + // Make sure the actual author is the AuthorID + // We need to replace apool attrToNum value where the first value before + // the comma is author with authorId + var attrToNum = apool.attribToNum; + if(attrToNum){ + for (var attr in attrToNum){ + var splitAttr = attr.split(','); + var isAuthor = (splitAttr[0] === 'author'); // Is it an author val? + if (isAuthor){ + // We force write the author over a change, for sanity n stuff + var newValue = 'author,'+authorId; // Create a new value + var key = attrToNum[attr]; // Key is actually the value + delete apool.attribToNum[attr]; // Delete the old value + apool.attribToNum[newValue] = key; // Write a new value + } + } + } + if (Changeset.isIdentity(userChangeset)) toSubmit = null; else toSubmit = userChangeset; } |