#96 and some other fixed. Now inserting new comments as HTML (new WebSocket message format).

This commit is contained in:
Alexey Skobkin 2016-05-09 03:33:31 +03:00
parent 75bc6636b2
commit f91dfc4ba7

View file

@ -362,11 +362,23 @@ function PointPlus(ppVersion) {
if (evt.data === 'ping') { if (evt.data === 'ping') {
console.info('ws-ping'); console.info('ws-ping');
} else { } 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); var wsMessage = JSON.parse(evt.data);
if (wsMessage.hasOwnProperty('a') && wsMessage.a !== '') { if (wsMessage.hasOwnProperty('a') && wsMessage.a !== '') {
console.log(wsMessage); console.log(wsMessage);
switch (wsMessage.a) { switch (wsMessage.a) {
// Recommendation comment // Recommendation comment
case 'ok': case 'ok':
@ -407,7 +419,7 @@ function PointPlus(ppVersion) {
toId: wsMessage.to_comment_id, toId: wsMessage.to_comment_id,
postId: wsMessage.post_id, postId: wsMessage.post_id,
author: wsMessage.author, author: wsMessage.author,
text: wsMessage.text, html: wsMessage.html,
fadeOut: options.is('option_ws_comments_color_fadeout'), 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, 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|number} commentData.toId ID of the comment replying to
* @param {string} commentData.postId ID of the post * @param {string} commentData.postId ID of the post
* @param {string} commentData.author Author of the comment * @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} commentData.fadeOut Is fadeout enabled or not
* @param {boolean|null} commentData.isRec Is comment also a recommendation * @param {boolean|null} commentData.isRec Is comment also a recommendation
* @param {boolean} commentData.unread Is comment unread * @param {boolean} commentData.unread Is comment unread
@ -629,7 +641,7 @@ function create_comment_elements(commentData, onCommentCreated) {
///Crutchy fix ///Crutchy fix
.append($('<span>').html(date.getHours() + ':' + ((date.getMinutes().toString().length < 2) ? ('0' + date.getMinutes().toString()) : (date.getMinutes().toString())))); .append($('<span>').html(date.getHours() + ':' + ((date.getMinutes().toString().length < 2) ? ('0' + date.getMinutes().toString()) : (date.getMinutes().toString()))));
// Comment text // Comment text
$commentTemplate.find('.text').append($('<p>').text(commentData.text)); $commentTemplate.find('.text').html(commentData.html);
// Author // Author
$commentTemplate.find('.author a.user').attr('href', userLink).text(commentData.author); $commentTemplate.find('.author a.user').attr('href', userLink).text(commentData.author);
// Avatar and link // Avatar and link