mirror of
https://bitbucket.org/skobkin/chrome_point_plus.git
synced 2024-11-23 18:56:04 +00:00
Merged in isqua/chrome_point_plus/refactor_unique_comments (pull request #36) Remove bquery_ajax from unique comments counter
This commit is contained in:
commit
5f88797a93
|
@ -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 */
|
||||
|
|
|
@ -934,48 +934,41 @@ function audio_extension_to_mime(extension) {
|
|||
}
|
||||
}
|
||||
|
||||
// Плашки с кол-вом уникальных пользователей и рекомендаций у постов
|
||||
/**
|
||||
* Показывает количество рекомендаций и комментаторов у постов
|
||||
*/
|
||||
function set_posts_count_label() {
|
||||
var ids = [];
|
||||
var posts = {};
|
||||
var ids;
|
||||
|
||||
$('.content-wrap > .post').each(function(n, post) {
|
||||
var $post = $(post);
|
||||
var postId = $post.data('id');
|
||||
|
||||
posts[postId] = $post;
|
||||
});
|
||||
|
||||
ids = Object.keys(posts);
|
||||
|
||||
$('.content-wrap > .post .post-id a .cn').addClass('changed_background');
|
||||
|
||||
$('.content-wrap > .post').each(function(num, obj) {
|
||||
var t = $(obj).attr('data-comment-id');
|
||||
if (typeof(t) !== 'undefined') {
|
||||
return;
|
||||
$.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(
|
||||
'<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 id = $(obj).attr('data-id');
|
||||
ids.push(id);
|
||||
});
|
||||
|
||||
$ajax({
|
||||
'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) {
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue