mirror of
https://bitbucket.org/skobkin/chrome_point_plus.git
synced 2024-11-23 18:56:04 +00:00
#78 fixed. Null recomendations comments fixed. WS close messages in console.
This commit is contained in:
parent
072ece28cd
commit
6ee91fbb25
|
@ -24,6 +24,9 @@ function PointPlus(ppVersion) {
|
||||||
|
|
||||||
// Getting username
|
// Getting username
|
||||||
var point_username = $('#name h1').text();
|
var point_username = $('#name h1').text();
|
||||||
|
// Getting post id
|
||||||
|
var postId = $('#top-post').attr('data-id');
|
||||||
|
console.debug('Current post id detected as #%s', postId);
|
||||||
|
|
||||||
// Проверяем, загрузились ли мы
|
// Проверяем, загрузились ли мы
|
||||||
var point_plus_debug = $('#point-plus-debug');
|
var point_plus_debug = $('#point-plus-debug');
|
||||||
|
@ -387,9 +390,6 @@ function PointPlus(ppVersion) {
|
||||||
ws = new WebSocket(((location.protocol == 'https:') ? 'wss' : 'ws') + '://point.im/ws');
|
ws = new WebSocket(((location.protocol == 'https:') ? 'wss' : 'ws') + '://point.im/ws');
|
||||||
console.log('WebSocket created: %O', ws);
|
console.log('WebSocket created: %O', ws);
|
||||||
|
|
||||||
// Detecting post id if presented
|
|
||||||
var postId = $('#top-post').attr('data-id');
|
|
||||||
console.debug('Current post id detected as #%s', postId);
|
|
||||||
// Detecting view mode
|
// Detecting view mode
|
||||||
treeSwitch = $('#tree-switch a.active').attr('href');
|
treeSwitch = $('#tree-switch a.active').attr('href');
|
||||||
console.debug('Comments view mode: %s', treeSwitch);
|
console.debug('Comments view mode: %s', treeSwitch);
|
||||||
|
@ -399,6 +399,12 @@ function PointPlus(ppVersion) {
|
||||||
console.error('WebSocket error: %O', err);
|
console.error('WebSocket error: %O', err);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Close handler
|
||||||
|
ws.onclose = function(evt) {
|
||||||
|
console.error('WebSocket closed: %O', evt);
|
||||||
|
};
|
||||||
|
|
||||||
|
// todo: refactor to background service
|
||||||
// Message handler
|
// Message handler
|
||||||
ws.onmessage = function(evt) {
|
ws.onmessage = function(evt) {
|
||||||
try {
|
try {
|
||||||
|
@ -430,14 +436,10 @@ function PointPlus(ppVersion) {
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
case 'comment':
|
case 'comment':
|
||||||
if (wsMessage.a === 'comment') {
|
console.groupCollapsed('WS \'%s\' #%s/%s', wsMessage.a, wsMessage.post_id, wsMessage.comment_id);
|
||||||
console.groupCollapsed('WS comment #%s/%s', wsMessage.post_id, wsMessage.comment_id);
|
|
||||||
} else if (wsMessage.a === 'ok') {
|
|
||||||
console.groupCollapsed('WS comment rec #%s/%s', wsMessage.post_id, wsMessage.comment_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check option
|
// Check option
|
||||||
if ( ! options.is('option_ws_comments')) {
|
if (!options.is('option_ws_comments')) {
|
||||||
console.log('Comments processing disabled');
|
console.log('Comments processing disabled');
|
||||||
console.groupEnd();
|
console.groupEnd();
|
||||||
break;
|
break;
|
||||||
|
@ -457,6 +459,8 @@ function PointPlus(ppVersion) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If comment has text
|
||||||
|
if (wsMessage.hasOwnProperty('html') && typeof wsMessage.html === 'string') {
|
||||||
// Generating comment from websocket message
|
// Generating comment from websocket message
|
||||||
create_comment_elements({
|
create_comment_elements({
|
||||||
id: (wsMessage.a === 'ok') ? wsMessage.rcid : wsMessage.comment_id,
|
id: (wsMessage.a === 'ok') ? wsMessage.rcid : wsMessage.comment_id,
|
||||||
|
@ -506,7 +510,7 @@ function PointPlus(ppVersion) {
|
||||||
|
|
||||||
console.groupEnd();
|
console.groupEnd();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue