From 13aa8595e77f9f9c2c0b3552628109c6df927303 Mon Sep 17 00:00:00 2001 From: isqua Date: Wed, 28 Jan 2015 23:45:59 +0300 Subject: [PATCH] Remove bquery_ajax from unique comments counter --- chrome_point_plus/css/point-plus.css | 29 ++++++++----- chrome_point_plus/js/point-plus.js | 63 +++++++++++++--------------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/chrome_point_plus/css/point-plus.css b/chrome_point_plus/css/point-plus.css index 5c7ab56..e2c959c 100644 --- a/chrome_point_plus/css/point-plus.css +++ b/chrome_point_plus/css/point-plus.css @@ -39,20 +39,29 @@ div#markItUpText-input { max-height: 300px; } -/* Labels in post */ -.post .post-id a .cn.changed_background { +/* Unique ID and Recomendation */ +.pp-post-counters +{ + float: left; + color: #999; + font-size: 12px; + margin-left: 1em; } -.post .post-id a .authors_unique_count, .post .post-id a .recommendation_count { - padding: 0 .5em; - font-weight: normal; - color: #35587c; - background-color: #f2f2eb; +.pp-unique-comments +{ + margin-right: .5em; } -.post .post-id a .recommendation_count { - margin-left: 0.2em; - background-color: #f2eceb; +/* @todo i18n */ +.pp-unique-comments::before +{ + content: 'Комментаторов: '; +} + +.pp-recommendation-count::before +{ + content: 'Рекомендаций: '; } /* NSFW-content */ diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index be29774..e931d81 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -8,7 +8,7 @@ messenger.sendMessage({ }); messenger.sendMessage({ - type: 'getManifestVersion' + type: 'getManifestVersion' }, function(response) { $(document).ready(function() { PointPlus(response.version || 'undefined') @@ -937,48 +937,41 @@ function audio_extension_to_mime(extension) { } } -// Плашки с кол-вом уникальных пользователей и рекомендаций у постов +/** + * Показывает количество рекомендаций и комментаторов у постов + */ function set_posts_count_label() { - var ids = []; - $('.content-wrap > .post .post-id a .cn').addClass('changed_background'); + var posts = {}; + var ids; + + $('.content-wrap > .post').each(function(n, post) { + var $post = $(post); + var postId = $post.data('id'); - $('.content-wrap > .post').each(function(num, obj) { - var t = $(obj).attr('data-comment-id'); - if (typeof(t) !== 'undefined') { - return; - } - var id = $(obj).attr('data-id'); - ids.push(id); + posts[postId] = $post; }); - $ajax({ - 'url': 'https://api.kanaria.ru/point/get_post_info.php?list=' + urlencode(ids.join(',')), - 'success': function(a) { - var answer = JSON.parse(a); + ids = Object.keys(posts); - $('.content-wrap > .post').each(function(num, obj) { - var id = $(obj).attr('data-id'); - var postid = $(obj).find('.post-id a')[0]; - var t = $(obj).attr('data-comment-id'); - if (typeof(t) !== 'undefined') { - return; + $('.content-wrap > .post .post-id a .cn').addClass('changed_background'); + + $.ajax('https://api.kanaria.ru/point/get_post_info.php?list=' + encodeURIComponent(ids.join(',')), { + dataType: 'json', + success: function(data) { + ids.forEach(function(id) { + var postInfo = data.list[id]; + + if (postInfo) { + posts[id].find('.post-id').after( + '
' + + '' + postInfo.count_comment_unique + ' ' + + '' + postInfo.count_recommendation + ' ' + + '
' + ) } - - var e1 = document.createElement('span'); - if (typeof(answer.list[id]) == 'undefined') { - return; - } - $(e1).addClass('authors_unique_count').text(answer.list[id].count_comment_unique).attr('title', 'Количество комментаторов'); - postid.appendChild(e1); - - var e2 = document.createElement('span'); - $(e2).addClass('recommendation_count').text('~' + answer.list[id].count_recommendation).attr('title', 'Количество рекомендаций. Работает криво, спасибо @arts\'у за это'); - postid.appendChild(e2); }); } - - }) - + }); } function parse_pleercom_links(current_options) {