mirror of
https://bitbucket.org/skobkin/chrome_point_plus.git
synced 2024-11-23 10:46:02 +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
|
||||
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');
|
||||
|
@ -387,9 +390,6 @@ function PointPlus(ppVersion) {
|
|||
ws = new WebSocket(((location.protocol == 'https:') ? 'wss' : 'ws') + '://point.im/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
|
||||
treeSwitch = $('#tree-switch a.active').attr('href');
|
||||
console.debug('Comments view mode: %s', treeSwitch);
|
||||
|
@ -399,6 +399,12 @@ function PointPlus(ppVersion) {
|
|||
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
|
||||
ws.onmessage = function(evt) {
|
||||
try {
|
||||
|
@ -430,11 +436,7 @@ function PointPlus(ppVersion) {
|
|||
|
||||
// Comments
|
||||
case 'comment':
|
||||
if (wsMessage.a === 'comment') {
|
||||
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);
|
||||
}
|
||||
console.groupCollapsed('WS \'%s\' #%s/%s', wsMessage.a, wsMessage.post_id, wsMessage.comment_id);
|
||||
|
||||
// Check option
|
||||
if (!options.is('option_ws_comments')) {
|
||||
|
@ -457,6 +459,8 @@ function PointPlus(ppVersion) {
|
|||
break;
|
||||
}
|
||||
|
||||
// If comment has text
|
||||
if (wsMessage.hasOwnProperty('html') && typeof wsMessage.html === 'string') {
|
||||
// Generating comment from websocket message
|
||||
create_comment_elements({
|
||||
id: (wsMessage.a === 'ok') ? wsMessage.rcid : wsMessage.comment_id,
|
||||
|
@ -506,7 +510,7 @@ function PointPlus(ppVersion) {
|
|||
|
||||
console.groupEnd();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue