From f91dfc4ba725a3c35502214827a21fa1e48fbcaa Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Mon, 9 May 2016 03:33:31 +0300 Subject: [PATCH] #96 and some other fixed. Now inserting new comments as HTML (new WebSocket message format). --- chrome_point_plus/js/point-plus.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index bdd9829..da4f5a3 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -362,11 +362,23 @@ function PointPlus(ppVersion) { if (evt.data === 'ping') { console.info('ws-ping'); } else { + /** + * @namespace + * @property {string} a Message type ("comment" or "post") + * @property {string} author + * @property {number} comment_id + * @property {?Array} files + * @property {?string} html + * @property {string} post_id + * @property {?string} text + * @property {?number} to_comment_id + * @property {?string} to_text + */ var wsMessage = JSON.parse(evt.data); if (wsMessage.hasOwnProperty('a') && wsMessage.a !== '') { console.log(wsMessage); - + switch (wsMessage.a) { // Recommendation comment case 'ok': @@ -407,7 +419,7 @@ function PointPlus(ppVersion) { toId: wsMessage.to_comment_id, postId: wsMessage.post_id, author: wsMessage.author, - text: wsMessage.text, + html: wsMessage.html, fadeOut: options.is('option_ws_comments_color_fadeout'), isRec: (wsMessage.a === 'ok') ? true : false, unread: (point_username && point_username !== wsMessage.author) ? true : false, @@ -585,7 +597,7 @@ var months = [ * @param {string|number} commentData.toId ID of the comment replying to * @param {string} commentData.postId ID of the post * @param {string} commentData.author Author of the comment - * @param {string} commentData.text Text of the comment + * @param {string} commentData.html HTML of the comment text * @param {boolean} commentData.fadeOut Is fadeout enabled or not * @param {boolean|null} commentData.isRec Is comment also a recommendation * @param {boolean} commentData.unread Is comment unread @@ -629,7 +641,7 @@ function create_comment_elements(commentData, onCommentCreated) { ///Crutchy fix .append($('').html(date.getHours() + ':' + ((date.getMinutes().toString().length < 2) ? ('0' + date.getMinutes().toString()) : (date.getMinutes().toString())))); // Comment text - $commentTemplate.find('.text').append($('

').text(commentData.text)); + $commentTemplate.find('.text').html(commentData.html); // Author $commentTemplate.find('.author a.user').attr('href', userLink).text(commentData.author); // Avatar and link