diff options
author | Constantin Jucovschi <jucovschi@gmail.com> | 2012-02-26 12:18:17 +0000 |
---|---|---|
committer | Constantin Jucovschi <jucovschi@gmail.com> | 2012-02-26 12:59:20 +0000 |
commit | e318e3d4cb59c9be2ee5831bb03f2787f3c0371a (patch) | |
tree | 21eff8efdac6eb98509e7e7973f82b22b1e04112 /static | |
parent | ac86535cdf0e6f6282385e246725334a826d2acc (diff) | |
download | etherpad-lite-e318e3d4cb59c9be2ee5831bb03f2787f3c0371a.zip |
some new docs
Diffstat (limited to 'static')
-rw-r--r-- | static/js/Changeset.js | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/static/js/Changeset.js b/static/js/Changeset.js index ee99e76c..42a8f0dc 100644 --- a/static/js/Changeset.js +++ b/static/js/Changeset.js @@ -305,7 +305,12 @@ exports.checkRep = function (cs) { /** - * ==================== Changeset Functions ======================= + * ==================== Util Functions ======================= + */ + +/** + * creates an object that allows you to append operations (type Op) and also + * compresses them if possible */ exports.smartOpAssembler = function () { // Like opAssembler but able to produce conforming exportss @@ -563,6 +568,10 @@ if (_opt) { }; } +/** + * A custom made String Iterator + * @param str {string} String to be iterated over + */ exports.stringIterator = function (str) { var curIndex = 0; @@ -599,6 +608,9 @@ exports.stringIterator = function (str) { }; }; +/** + * A custom made StringBuffer + */ exports.stringAssembler = function () { var pieces = []; @@ -891,6 +903,11 @@ exports.applyZip = function (in1, idx1, in2, idx2, func) { return assem.toString(); }; +/** + * Unpacks a string encoded Changeset into a proper Changeset object + * @params cs {string} String encoded Changeset + * @returns {Changeset} a Changeset class + */ exports.unpack = function (cs) { var headerRegex = /Z:([0-9a-z]+)([><])([0-9a-z]+)|/; var headerMatch = headerRegex.exec(cs); @@ -912,6 +929,14 @@ exports.unpack = function (cs) { }; }; +/** + * Packs Changeset object into a string + * @params oldLen {int} Old length of the Changeset + * @params newLen {int] New length of the Changeset + * @params opsStr {string} String encoding of the changes to be made + * @params bank {string} Charbank of the Changeset + * @returns {Changeset} a Changeset class + */ exports.pack = function (oldLen, newLen, opsStr, bank) { var lenDiff = newLen - oldLen; var lenDiffStr = (lenDiff >= 0 ? '>' + exports.numToString(lenDiff) : '<' + exports.numToString(-lenDiff)); @@ -920,6 +945,11 @@ exports.pack = function (oldLen, newLen, opsStr, bank) { return a.join(''); }; +/** + * Applies a Changeset to a string + * @params cs {string} String encoded Changeset + * @params str {string} String to which a Changeset should be applied + */ exports.applyToText = function (cs, str) { var unpacked = exports.unpack(cs); exports.assert(str.length == unpacked.oldLen, "mismatched apply: ", str.length, " / ", unpacked.oldLen); @@ -1499,6 +1529,12 @@ exports.mapAttribNumbers = function (cs, func) { return newUpToDollar + cs.substring(dollarPos); }; +/** + * Create a Changeset going from Identity to a certain state + * @params text {string} text of the final change + * @attribs attribs {string} optional, operations which insert + * the text and also puts the right attributes + */ exports.makeAText = function (text, attribs) { return { text: text, |