Index: lams_build/conf/etherpad/etherpad-lite/node_modules/ep_export_authors/index.js
===================================================================
diff -u
--- lams_build/conf/etherpad/etherpad-lite/node_modules/ep_export_authors/index.js (revision 0)
+++ lams_build/conf/etherpad/etherpad-lite/node_modules/ep_export_authors/index.js (revision 6946c68b5b9aa12ff981659d94ecb5917552fdb8)
@@ -0,0 +1,100 @@
+var Changeset = require("ep_etherpad-lite/static/js/Changeset");
+var db = require("ep_etherpad-lite/node/db/DB").db;
+//var async = require("async");
+
+var authorColorPool = null;
+
+exports.getLineHTMLForExport = function (hook, context) {
+ if (context.text.indexOf("data-tables") != -1) {
+ // do not touch ice_tables content
+ return context.lineContent;
+ }
+
+ var authors = _authorsOfLine(context.attribLine, context.apool);
+ var newLineHTML = "";
+ var charPos = 0;
+
+ // Use this code if this function is called in an asynchronous way
+ /*async.series([
+ function(cb){
+ async.each(authors, function(author, callback) {
+ console.log(author);
+ db.getSub("globalAuthor:" + author, ["colorId"], function(err, result) {
+ if (err) {
+ console.log(err);
+ } else {
+ console.log("color: "+result);
+ newLineHTML += _getHTMLString(author.name.replace('.','_'), result, context.text.substring(charPos, charPos + author.chars));
+ charPos += author.chars;
+ }
+ callback();
+ });
+ }, function(err) {
+ if (err) {
+ console.log(err);
+ }
+ cb();
+ });
+ }
+ ],
+ function(err, results){
+ return newLineHTML+'
';
+ });*/
+
+ authors.forEach(function(author) {
+ var authorName = author.name;
+ var color = null;
+
+ if (authorName) {
+ authorName = authorName.replace('.','_');
+ color = _getAuthorColor(author.name);
+ }
+ newLineHTML += _getHTMLString(authorName, color, context.text.substring(charPos, charPos + author.chars));
+ charPos += author.chars;
+ });
+ if (newLineHTML == "") {
+ return;
+ }
+ return context.lineContent = newLineHTML;
+}
+
+function _authorsOfLine(alineAttrs, apool) {
+ var authors = [];
+ if (alineAttrs) {
+ var opIter = Changeset.opIterator(alineAttrs);
+ while (opIter.hasNext()) {
+ var op = opIter.next();
+ var author = null;
+ if (op.attribs) {
+ author= Changeset.attribsAttributeValue(op.attribs, "author", apool);
+ }
+ authors.push({ 'name': author, 'chars': op.chars});
+ }
+ }
+ return authors;
+}
+
+function _getHTMLString(authorName, authorColor, text) {
+ if (authorName) {
+ return ' ';
+ } else {
+ return '' + text + '';
+ }
+}
+
+function _getAuthorColor(authorName) {
+ var hashKey = "authorColor:"+authorName;
+ var color = "FF0000";
+
+ if (!authorColorPool) {
+ authorColorPool = [];
+ }
+ if (authorColorPool) {
+ if (!authorColorPool[hashKey]) {
+ authorColorPool[hashKey] = ('000000' + (Math.random()*0xFFFFFF<<0).toString(16)).slice(-6);
+ }
+ color = authorColorPool[hashKey];
+ }
+ return "#"+color;
+}
+
Index: lams_build/conf/etherpad/etherpad-lite/node_modules/ep_ice_tables/static/js/datatables-renderer.js
===================================================================
diff -u -rc83cefc8bdfd1eb8860c4d8c56b1468d0eea5079 -r6946c68b5b9aa12ff981659d94ecb5917552fdb8
--- lams_build/conf/etherpad/etherpad-lite/node_modules/ep_ice_tables/static/js/datatables-renderer.js (.../datatables-renderer.js) (revision c83cefc8bdfd1eb8860c4d8c56b1468d0eea5079)
+++ lams_build/conf/etherpad/etherpad-lite/node_modules/ep_ice_tables/static/js/datatables-renderer.js (.../datatables-renderer.js) (revision 6946c68b5b9aa12ff981659d94ecb5917552fdb8)
@@ -31,7 +31,6 @@
// element = element.children[0];
// console.log("getting child element", element.innerHTML, element);
// }
-
return element.innerHTML;
}
}; // end of dRenderer
@@ -95,8 +94,10 @@
htmlTbl += "