From eecd3133b8397fd267eb533b4b9256141cd0d644 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Mon, 9 May 2016 03:18:24 +0300 Subject: [PATCH] #98 fixed. Adding new comments with 'unread' class. --- chrome_point_plus/js/point-plus.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index c02fc7f..bdd9829 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -22,6 +22,9 @@ function PointPlus(ppVersion) { console.group('point-plus'); console.info('Point+ %s', ppVersion); + // Getting username + var point_username = $('#name h1').text(); + // Проверяем, загрузились ли мы var point_plus_debug = $('#point-plus-debug'); if (point_plus_debug.length > 0) { @@ -397,7 +400,7 @@ function PointPlus(ppVersion) { console.groupEnd(); break; } - + // Generating comment from websocket message create_comment_elements({ id: (wsMessage.a === 'ok') ? wsMessage.rcid : wsMessage.comment_id, @@ -406,7 +409,8 @@ function PointPlus(ppVersion) { author: wsMessage.author, text: wsMessage.text, fadeOut: options.is('option_ws_comments_color_fadeout'), - isRec: (wsMessage.a === 'ok') ? true : false + isRec: (wsMessage.a === 'ok') ? true : false, + unread: (point_username && point_username !== wsMessage.author) ? true : false, }, function($comment) { // It's time to DOM console.info('Inserting comment'); @@ -584,6 +588,7 @@ var months = [ * @param {string} commentData.text Text of the comment * @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 * @param {function} onCommentCreated Callback which is called when comment is ready * */ @@ -592,7 +597,7 @@ function create_comment_elements(commentData, onCommentCreated) { // Initializing comment element var $commentTemplate = $('
').attr({ - 'class': 'post', + 'class': 'post' + (commentData.unread ? ' unread' : ''), 'data-id': commentData.postId, 'data-comment-id': commentData.id, 'data-to-comment-id': commentData.id || ''