Merged in isqua/chrome_point_plus/refactor_unique_comments (pull request #36) Remove bquery_ajax from unique comments counter

This commit is contained in:
Alexey Skobkin 2015-01-31 08:34:33 +03:00
commit 5f88797a93
2 changed files with 47 additions and 45 deletions

View file

@ -39,20 +39,29 @@ div#markItUpText-input {
max-height: 300px; max-height: 300px;
} }
/* Labels in post */ /* Unique ID and Recomendation */
.post .post-id a .cn.changed_background { .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 { .pp-unique-comments
padding: 0 .5em; {
font-weight: normal; margin-right: .5em;
color: #35587c;
background-color: #f2f2eb;
} }
.post .post-id a .recommendation_count { /* @todo i18n */
margin-left: 0.2em; .pp-unique-comments::before
background-color: #f2eceb; {
content: 'Комментаторов: ';
}
.pp-recommendation-count::before
{
content: 'Рекомендаций: ';
} }
/* NSFW-content */ /* NSFW-content */

View file

@ -8,7 +8,7 @@ messenger.sendMessage({
}); });
messenger.sendMessage({ messenger.sendMessage({
type: 'getManifestVersion' type: 'getManifestVersion'
}, function(response) { }, function(response) {
$(document).ready(function() { $(document).ready(function() {
PointPlus(response.version || 'undefined') PointPlus(response.version || 'undefined')
@ -934,48 +934,41 @@ function audio_extension_to_mime(extension) {
} }
} }
// Плашки с кол-вом уникальных пользователей и рекомендаций у постов /**
* Показывает количество рекомендаций и комментаторов у постов
*/
function set_posts_count_label() { function set_posts_count_label() {
var ids = []; var posts = {};
$('.content-wrap > .post .post-id a .cn').addClass('changed_background'); var ids;
$('.content-wrap > .post').each(function(num, obj) { $('.content-wrap > .post').each(function(n, post) {
var t = $(obj).attr('data-comment-id'); var $post = $(post);
if (typeof(t) !== 'undefined') { var postId = $post.data('id');
return;
} posts[postId] = $post;
var id = $(obj).attr('data-id');
ids.push(id);
}); });
$ajax({ ids = Object.keys(posts);
'url': 'https://api.kanaria.ru/point/get_post_info.php?list=' + urlencode(ids.join(',')),
'success': function(a) {
var answer = JSON.parse(a);
$('.content-wrap > .post').each(function(num, obj) { $('.content-wrap > .post .post-id a .cn').addClass('changed_background');
var id = $(obj).attr('data-id');
var postid = $(obj).find('.post-id a')[0]; $.ajax('https://api.kanaria.ru/point/get_post_info.php?list=' + encodeURIComponent(ids.join(',')), {
var t = $(obj).attr('data-comment-id'); dataType: 'json',
if (typeof(t) !== 'undefined') { success: function(data) {
return; ids.forEach(function(id) {
var postInfo = data.list[id];
if (postInfo) {
posts[id].find('.post-id').after(
'<div class="pp-post-counters">' +
'<span class="pp-unique-comments">' + postInfo.count_comment_unique + '</span> ' +
'<span class="pp-recommendation-count">' + postInfo.count_recommendation + '</span> ' +
'</div>'
)
} }
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) { function parse_pleercom_links(current_options) {