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 '' + text + ''; + } 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 += ""; - var preHeader = j == 0 ? "{\"payload\":[[\"" : ""; - htmlTbl += "" + preHeader + ""; + if (renderingContext != "export") { + var preHeader = j == 0 ? "{\"payload\":[[\"" : ""; + htmlTbl += "" + preHeader + ""; + } var singleRowAttr = typeof (singleRowAttrs) == 'undefined' || singleRowAttrs == null ? null : singleRowAttrs[j]; for (var i = 0, tl = tds.length; i < tl; i++) { var cellAttr = typeof (cellAttrs[j]) == 'undefined' || cellAttrs[j] == null ? null : cellAttrs[j][i]; @@ -109,8 +110,7 @@ //col vAlign var colVAlign = typeof (colAttrs[i]) == 'undefined' || colAttrs[i] == null ? "" : "align='" + colAttrs[i].colVAlign + "'" || ""; var quoteAndComma = "\",\""; - var cellDel = ""; - var delimCell = "" + quoteAndComma + ""; + var delimCell = "" + quoteAndComma + ""; var lastCellBorder = ""; if (i == tl - 1) { delimCell = ""; @@ -128,13 +128,21 @@ } htmlTbl += "" + cellsWithBr + - "
" + delimCell; + "
"; + if (renderingContext != "export") { + htmlTbl += delimCell; + } } else { - htmlTbl += "" + tds[i] + "" + "
" + delimCell + htmlTbl += "" + tds[i] + "" + "
"; + if (renderingContext != "export") { + htmlTbl += delimCell; + } } } var bracketAndcomma = "\"]],\"tblId\":\"1\",\"tblClass\":\"data-tables\", \"tblProperties\":" + JSON.stringify(tblProperties) + "}"; - htmlTbl += "" + bracketAndcomma + ""; + if (renderingContext != "export") { + htmlTbl += "" + bracketAndcomma + ""; + } htmlTbl += ""; } htmlTbl += "";