Index: lams_build/conf/etherpad/etherpad-lite/node_modules/ep_comments_page/static/js/index.js =================================================================== diff -u -r7ba9b61ebdd7931c2db2078f365b10f2b9c776ad -r7e538478d53f4820e1e14acb1b1a648ab808bfda --- lams_build/conf/etherpad/etherpad-lite/node_modules/ep_comments_page/static/js/index.js (.../index.js) (revision 7ba9b61ebdd7931c2db2078f365b10f2b9c776ad) +++ lams_build/conf/etherpad/etherpad-lite/node_modules/ep_comments_page/static/js/index.js (.../index.js) (revision 7e538478d53f4820e1e14acb1b1a648ab808bfda) @@ -6,7 +6,7 @@ */ -const _ = require('ep_etherpad-lite/static/js/underscore'); +const _ = require('underscore'); const browser = require('ep_etherpad-lite/static/js/browser'); const commentBoxes = require('ep_comments_page/static/js/commentBoxes'); const commentIcons = require('ep_comments_page/static/js/commentIcons'); @@ -49,9 +49,12 @@ const loc = document.location; const port = loc.port === '' ? (loc.protocol === 'https:' ? 443 : 80) : loc.port; const url = `${loc.protocol}//${loc.hostname}:${port}/comment`; - this.socket = io.connect(url); this.padId = clientVars.padId; + this.socket = io.connect(url, { + query: `padId=${this.padId}`, + }); + this.comments = []; this.commentReplies = {}; this.mapFakeComments = []; @@ -341,10 +344,17 @@ // Enable and handle cookies - // LAMS modifies this logic so right comments bar is hidden by default + if (padcookie.getPref('comments') === false) { + this.padOuter.find('#comments, #commentIcons').removeClass('active'); + $('#options-comments').attr('checked', 'unchecked'); + $('#options-comments').attr('checked', false); + } else { + $('#options-comments').attr('checked', 'checked'); + } + + // LAMS modified this logic so right comments bar is hidden by default $('#options-comments').prop('checked', padcookie.getPref('comments') === true); - $('#options-comments').on('change', () => { const checked = $('#options-comments').is(':checked'); padcookie.setPref('comments', checked); @@ -596,7 +606,6 @@ comment.commentId = commentId; comment.reply = true; - content = $('#commentsTemplate').tmpl(comment); if (comment.author !== clientVars.userId) { $(content).find('.comment-actions-wrapper').addClass('hidden'); @@ -668,7 +677,8 @@ // avoid when it has a '.comment' that it has a fakeComment class 'fakecomment-123' yet. if (commentId && commentId[1]) return commentId[1]; }); - return _.uniq(commentsId); + const onlyUnique = (value, index, self) => self.indexOf(value) === index; + return commentsId.filter(onlyUnique); }; // Indicates if all comments are on the correct Y position, and don't need to @@ -887,9 +897,7 @@ rep.hasCommentsOnSelection = ace.ace_hasCommentOnSelection(); }, 'saveCommentedSelection', true); - const selectedText = this.getSelectedText(rep); - // we have nothing selected, do nothing const noTextSelected = (selectedText.length === 0); if (noTextSelected) { @@ -1271,7 +1279,7 @@ return cb(); }, - aceEditEvent: (hookName, context, cb) => { + aceEditEvent: (hookName, context) => { if (!pad.plugins) pad.plugins = {}; // first check if some text is being marked/unmarked to add comment to it const eventType = context.callstack.editEvent.eventType; @@ -1281,7 +1289,7 @@ pad.plugins.ep_comments_page.preCommentMarker.handleMarkText(context); } - if (['setup', 'setBaseText', 'importText'].includes(eventType)) return cb(); + if (['setup', 'setBaseText', 'importText'].includes(eventType)) return; if (context.callstack.docTextChanged && pad.plugins.ep_comments_page) { pad.plugins.ep_comments_page.setYofComments(); @@ -1300,7 +1308,7 @@ }); } } - return cb(); + return; }, // Insert comments classes @@ -1315,7 +1323,7 @@ return cb(); }, - aceEditorCSS: (hookName, context, cb) => cb(cssFiles), + aceEditorCSS: (hookName, context) => cssFiles, }; exports.aceEditorCSS = hooks.aceEditorCSS; @@ -1414,10 +1422,10 @@ // Once ace is initialized, we set ace_doInsertHeading and bind it to the context exports.aceInitialized = (hookName, context, cb) => { const editorInfo = context.editorInfo; - isHeading = _(isHeading).bind(context); - editorInfo.ace_getRepFromSelector = _(getRepFromSelector).bind(context); + isHeading = isHeading.bind(context); + editorInfo.ace_getRepFromSelector = getRepFromSelector.bind(context); editorInfo.ace_getCommentIdOnFirstPositionSelected = - _(getCommentIdOnFirstPositionSelected).bind(context); - editorInfo.ace_hasCommentOnSelection = _(hasCommentOnSelection).bind(context); + getCommentIdOnFirstPositionSelected.bind(context); + editorInfo.ace_hasCommentOnSelection = hasCommentOnSelection.bind(context); return cb(); };