aboutsummaryrefslogtreecommitdiffstats
path: root/trunk/infrastructure/ace/www/easy_sync.js
diff options
context:
space:
mode:
authoralexanders@b2ef00c0-3703-41da-baef-cfe82387ac0c <none@none>2010-02-03 00:49:01 +0000
committeralexanders@b2ef00c0-3703-41da-baef-cfe82387ac0c <none@none>2010-02-03 00:49:01 +0000
commit200045a9b74bdfc6146b72747781e93d3f759df5 (patch)
tree9f583dfbe2508558d13c093c32326c1dac8badc2 /trunk/infrastructure/ace/www/easy_sync.js
parentfb518368b5d17f3f79115c2c5310c83e36106192 (diff)
downloadetherpad-200045a9b74bdfc6146b72747781e93d3f759df5.tar.gz
etherpad-200045a9b74bdfc6146b72747781e93d3f759df5.tar.xz
etherpad-200045a9b74bdfc6146b72747781e93d3f759df5.zip
fixed ACE build process; added ACE README
--HG-- extra : convert_revision : svn%3Ab2ef00c0-3703-41da-baef-cfe82387ac0c/trunk%406
Diffstat (limited to 'trunk/infrastructure/ace/www/easy_sync.js')
-rw-r--r--trunk/infrastructure/ace/www/easy_sync.js74
1 files changed, 37 insertions, 37 deletions
diff --git a/trunk/infrastructure/ace/www/easy_sync.js b/trunk/infrastructure/ace/www/easy_sync.js
index d4d309b..86a4327 100644
--- a/trunk/infrastructure/ace/www/easy_sync.js
+++ b/trunk/infrastructure/ace/www/easy_sync.js
@@ -1,12 +1,14 @@
+// THIS FILE IS ALSO AN APPJET MODULE: etherpad.collab.ace.easysync1
+
/**
* Copyright 2009 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -14,8 +16,6 @@
* limitations under the License.
*/
-// THIS FILE IS ALSO AN APPJET MODULE: etherpad.collab.ace.easysync1
-
function Changeset(arg) {
var array;
@@ -38,7 +38,7 @@ function Changeset(arg) {
else array = arg;
array.isChangeset = true;
-
+
// OOP style: attach generic methods to array object, hold no state in environment
//function error(msg) { top.console.error(msg); top.console.trace(); }
@@ -51,7 +51,7 @@ function Changeset(arg) {
return this.length == 6 && this[1] == this[2] && this[3] == 0 &&
this[4] == this[1] && this[5] == "";
}
-
+
array.eachStrip = function(func, thisObj) {
// inside "func", the method receiver will be "this" by default,
// or you can pass an object.
@@ -66,7 +66,7 @@ function Changeset(arg) {
array.numStrips = function() { return (this.length-3)/3; };
array.oldLen = function() { return this[1]; };
array.newLen = function() { return this[2]; };
-
+
array.checkRep = function() {
assert(this[0] == Changeset.MAGIC, "bad magic");
assert(this[1] >= 0, "bad old text length");
@@ -97,7 +97,7 @@ function Changeset(arg) {
});
assert(newLen == actualNewLen, "calculated new text length doesn't match");
}
-
+
array.applyToText = function(text) {
assert(text.length == this.oldLen(), "mismatched apply: "+text.length+" / "+this.oldLen());
var buf = [];
@@ -139,7 +139,7 @@ function Changeset(arg) {
C.authors = [_getNumInserted(C), author || ''];
return C;
}
-
+
array.builder = function() {
// normal pattern is Changeset(oldLength).builder().appendOldText(...). ...
// builder methods mutate this!
@@ -166,7 +166,7 @@ function Changeset(arg) {
C.authors.push(str.length, a);
}
}
-
+
return self;
},
appendOldText: function(startIndex, numTaken) {
@@ -193,7 +193,7 @@ function Changeset(arg) {
array.authorSlicer = function(outputBuilder) {
return _makeAuthorSlicer(this, outputBuilder);
}
-
+
function _makeAuthorSlicer(changesetOrAuthorsIn, builderOut) {
// "builderOut" only needs to support appendNewText
var authors; // considered immutable
@@ -203,13 +203,13 @@ function Changeset(arg) {
else {
authors = changesetOrAuthorsIn;
}
-
+
// OOP style: state in environment
var authorPtr = 0;
var charIndex = 0;
var charWithinAuthor = 0; // 0 <= charWithinAuthor <= authors[authorPtr]; max value iff atEnd
var atEnd = false;
- function curAuthor() { return authors[authorPtr+1]; }
+ function curAuthor() { return authors[authorPtr+1]; }
function curAuthorWidth() { return authors[authorPtr]; }
function assertNotAtEnd() { assert(! atEnd, "_authorSlicer: can't move past end"); }
function forwardInAuthor(numChars) {
@@ -225,7 +225,7 @@ function Changeset(arg) {
atEnd = true;
}
}
-
+
var self;
return self = {
skipChars: function(n) {
@@ -278,11 +278,11 @@ function Changeset(arg) {
}
};
}
-
+
function _makeSlicer(C, output) {
// C: Changeset, output: builder from _makeBuilder
// C is considered immutable, won't change or be changed
-
+
// OOP style: state in environment
var charIndex = 0; // 0 <= charIndex <= C.newLen(); maximum value iff atEnd
var stripIndex = 0; // 0 <= stripIndex <= C.numStrips(); maximum value iff atEnd
@@ -293,7 +293,7 @@ function Changeset(arg) {
if (C.authors) {
authorSlicer = _makeAuthorSlicer(C.authors, output);
}
-
+
var ptr = 3;
function curStartIndex() { return C[ptr]; }
function curNumTaken() { return C[ptr+1]; }
@@ -327,7 +327,7 @@ function Changeset(arg) {
if (e < s) return 0;
return e-s;
}
-
+
var self;
return self = {
skipChars: function (n) {
@@ -344,7 +344,7 @@ function Changeset(arg) {
if (authorSlicer)
authorSlicer.skipChars(curNumNewCharsInRange(charWithinStrip,
charWithinStrip + leftInStrip));
-
+
leftToSkip -= leftInStrip;
nextStrip();
}
@@ -352,7 +352,7 @@ function Changeset(arg) {
if (authorSlicer)
authorSlicer.skipChars(curNumNewCharsInRange(charWithinStrip,
charWithinStrip + leftToSkip));
-
+
forwardInStrip(leftToSkip);
leftToSkip = 0;
}
@@ -379,9 +379,9 @@ function Changeset(arg) {
charWithinStrip < curStripWidth()) {
// at least one char to take from current strip's newText
var leftInNewText = (curStripWidth() - charWithinStrip);
- assert(leftInNewText > 0, "_slicer: should have leftInNewText > 0");
+ assert(leftInNewText > 0, "_slicer: should have leftInNewText > 0");
var toTake = min(leftInNewText, leftToTake);
- assert(toTake > 0, "_slicer: should have toTake > 0");
+ assert(toTake > 0, "_slicer: should have toTake > 0");
var newText = curNewText().substr(charWithinStrip - curNumTaken(), toTake);
if (authorSlicer) {
authorSlicer.takeChars(newText.length, newText);
@@ -407,7 +407,7 @@ function Changeset(arg) {
array.slicer = function(outputBuilder) {
return _makeSlicer(this, outputBuilder);
}
-
+
array.compose = function(next) {
assert(next.oldLen() == this.newLen(), "mismatched composition");
@@ -418,7 +418,7 @@ function Changeset(arg) {
if (next.authors) {
authorSlicer = _makeAuthorSlicer(next.authors, builder);
}
-
+
next.eachStrip(function(s, t, n) {
slicer.skipTo(s);
slicer.takeChars(t);
@@ -436,7 +436,7 @@ function Changeset(arg) {
array.traverser = function() {
return _makeTraverser(this);
}
-
+
function _makeTraverser(C) {
var s = C[3], t = C[4], n = C[5];
var nextIndex = 6;
@@ -446,7 +446,7 @@ function Changeset(arg) {
if (C.authors) {
authorSlicer = _makeAuthorSlicer(C.authors, null);
}
-
+
function advanceIfPossible() {
if (t == 0 && n == "" && nextIndex < C.length) {
s = C[nextIndex];
@@ -561,7 +561,7 @@ function Changeset(arg) {
}
return builder.toChangeset();
}
-
+
array.encodeToString = function(asBinary) {
var stringDataArray = [];
var numsArray = [];
@@ -585,7 +585,7 @@ function Changeset(arg) {
return "\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4);
});
}
-
+
array.applyToAttributedText = Changeset.applyToAttributedText;
function splicesFromChanges(c) {
@@ -616,11 +616,11 @@ function Changeset(arg) {
}
return splices;
}
-
+
array.toSplices = function() {
return splicesFromChanges(this);
}
-
+
array.characterRangeFollowThis = function(selStartChar, selEndChar, insertionsAfter) {
var changeset = this;
// represent the selection as a changeset that replaces the selection with some finite string.
@@ -650,7 +650,7 @@ function Changeset(arg) {
}
return [selStartChar, selEndChar];
}
-
+
return array;
}
@@ -660,7 +660,7 @@ Changeset.makeSplice = function(oldLength, spliceStart, numRemoved, stringInsert
spliceStart = (spliceStart || 0);
numRemoved = (numRemoved || 0);
stringInserted = String(stringInserted || "");
-
+
var builder = Changeset(oldLength).builder();
builder.appendOldText(0, spliceStart);
builder.appendNewText(stringInserted);
@@ -688,7 +688,7 @@ Changeset.decodeFromString = function(str) {
return String.fromCharCode(Number("0x"+seq.substring(2)));
});
}
-
+
var numData, stringData;
var binary = false;
var typ = str.charAt(0);
@@ -765,7 +765,7 @@ Changeset.numberArrayFromString = function(str, startIndex) {
}
else {
// legacy format
- n = (((n & 0x1fff) << 16) | str.charCodeAt(strIndex++));
+ n = (((n & 0x1fff) << 16) | str.charCodeAt(strIndex++));
}
}
return n;
@@ -805,7 +805,7 @@ Changeset.numberArrayFromString = function(str, startIndex) {
}
return 0;
}
-
+
// emptyObj may be a StorableObject
Changeset.initAttributedText = function(emptyObj, initialString, initialAuthor) {
var obj = emptyObj;
@@ -894,7 +894,7 @@ Changeset.numberArrayFromString = function(str, startIndex) {
// call func(author, authorNum)
for(var a in atObj.authorMap) {
if (func(atObj.authorMap[a], Number(a))) break;
- }
+ }
};
Changeset.getAttributedTextAuthorByNum = function(atObj, n) {
return atObj.authorMap[n];