mirror of
https://bitbucket.org/skobkin/chrome_point_plus.git
synced 2024-12-28 17:24:20 +00:00
+ Обновление количества непрочитанных постов и комментариев в левом меню
This commit is contained in:
parent
0aa4e8c886
commit
c56e31c14c
|
@ -159,6 +159,9 @@
|
|||
"option_other_comments_nesting_level":{
|
||||
"message": "Comments Nesting level indicator"
|
||||
},
|
||||
"option_other_comments_count_refresh":{
|
||||
"message": "Refresh unread posts and comments count in left menu"
|
||||
},
|
||||
|
||||
"options_feedback_text": {
|
||||
"message": "<p>If you find an error do not hesitate to <a href=\"https:\/\/bitbucket.org\/skobkin\/chrome_point_plus\/issues?status=new&status=open\" target=\"_blank\">send me a bug report<\/a>.<\/p><p>Also you can make a donation in the following ways:<\/p><p><iframe frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" src=\"https:\/\/money.yandex.ru\/embed\/small.xml?account=41001539215836&quickpay=small&yamoney-payment-type=on&button-text=04&button-size=s&button-color=black&targets=Point%2B&default-sum=150&successURL=https%3A%2F%2Fbitbucket.org%2Fskobkin%2Fchrome_point_plus\" width=\"158\" height=\"31\"><\/p><p><\/iframe><\/p><p><iframe frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" src=\"https:\/\/money.yandex.ru\/embed\/small.xml?account=41001539215836&quickpay=small&any-card-payment-type=on&button-text=04&button-size=s&button-color=black&targets=Point%2B&default-sum=150&successURL=https%3A%2F%2Fbitbucket.org%2Fskobkin%2Fchrome_point_plus\" width=\"158\" height=\"31\"><\/iframe><\/p><p><form action=\"https:\/\/www.paypal.com\/cgi-bin\/webscr\" method=\"post\" target=\"_top\"><input type=\"hidden\" name=\"cmd\" value=\"_s-xclick\"><input type=\"hidden\" name=\"hosted_button_id\" value=\"RCW5V6UFXYTRE\"><input type=\"image\" src=\"https:\/\/www.paypalobjects.com\/ru_RU\/RU\/i\/btn\/btn_donateCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal — более безопасный и легкий способ оплаты через Интернет!\"><img alt=\"\" border=\"0\" src=\"https:\/\/www.paypalobjects.com\/en_US\/i\/scr\/pixel.gif\" width=\"1\" height=\"1\"><\/form><\/p>"
|
||||
|
|
|
@ -159,6 +159,9 @@
|
|||
"option_other_comments_nesting_level":{
|
||||
"message": "Индикатор уровня вложенности коммнентариев"
|
||||
},
|
||||
"option_other_comments_count_refresh":{
|
||||
"message": "Обновляем количество непрочитанных комментариев и постов в ленте"
|
||||
},
|
||||
|
||||
|
||||
"options_feedback_text": {
|
||||
|
|
|
@ -505,6 +505,11 @@ $(document).ready(function() {
|
|||
draw_nesting_level_indicator();
|
||||
}
|
||||
|
||||
// Обновляем кол-во постов и непрочитанных комментариев
|
||||
if (options.option_other_comments_count_refresh.value == true){
|
||||
set_comments_refresh_tick();
|
||||
}
|
||||
|
||||
$('#point-plus-debug').fadeOut(1000);
|
||||
});
|
||||
});
|
||||
|
@ -1189,4 +1194,56 @@ function draw_nesting_level_indicator_level(obj, level) {
|
|||
draw_nesting_level_indicator_level(comments, level + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Обновляем кол-во комментариев и непрочитанных новых постов в ленте
|
||||
*/
|
||||
function set_comments_refresh_tick() {
|
||||
// Проверяем, чтобы были баджи
|
||||
if ($('#main #left-menu #menu-recent .unread').length == 0) {
|
||||
$('#main #left-menu #menu-recent').append('<span class="unread" style="display: none;">');
|
||||
}
|
||||
if ($('#main #left-menu #menu-comments .unread').length == 0) {
|
||||
$('#main #left-menu #menu-comments').append('<span class="unread" style="display: none;">');
|
||||
}
|
||||
|
||||
// Ставим тик
|
||||
setInterval(comments_count_refresh_tick, 60000);
|
||||
}
|
||||
|
||||
// Проверка обновления комментариев, обновляется по крону
|
||||
function comments_count_refresh_tick() {
|
||||
$('#debug_iframe').remove();
|
||||
var iframe = document.createElement('iframe');
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
var current_user_name=$('#user-menu-label #name h1').text();
|
||||
$(iframe).on('load', function () {
|
||||
var a = $(iframe.contentDocument.body).find('#main #left-menu #menu-recent .unread');
|
||||
var b = $(iframe.contentDocument.body).find('#main #left-menu #menu-comments .unread');
|
||||
var count_recent = (a.length == 0) ? 0 : parseInt(a.text());
|
||||
var count_comments = (b.length == 0) ? 0 : parseInt(b.text());
|
||||
|
||||
console.log('Comments: ' + count_comments + ', Recent: ' + count_recent);
|
||||
if (count_recent > 0) {
|
||||
$('#main #left-menu #menu-recent .unread').text(count_recent).show();
|
||||
} else {
|
||||
$('#main #left-menu #menu-recent .unread').text('0').hide();
|
||||
}
|
||||
|
||||
if (count_comments > 0) {
|
||||
$('#main #left-menu #menu-comments .unread').text(count_comments).show();
|
||||
} else {
|
||||
$('#main #left-menu #menu-comments .unread').text('0').hide();
|
||||
}
|
||||
|
||||
$('#debug_iframe').remove();
|
||||
}).attr({
|
||||
'src': 'https://'+current_user_name+'.point.im/',
|
||||
'id': 'debug_iframe'
|
||||
}).css({
|
||||
'width': '600px',
|
||||
'height': '300px'
|
||||
}).hide();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Point+",
|
||||
"version": "1.18.1",
|
||||
"version": "1.18.2",
|
||||
"default_locale": "ru",
|
||||
"author": "__MSG_ext_author__",
|
||||
"homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus",
|
||||
|
|
|
@ -174,6 +174,10 @@
|
|||
<div class="option-node">
|
||||
<input type="checkbox" class="option-boolean" id="option-other-comments-nesting-level"><label for="option-other-comments-nesting-level" data-i18n="option_other_comments_nesting_level"></label>
|
||||
</div>
|
||||
|
||||
<div class="option-node">
|
||||
<input type="checkbox" class="option-boolean" id="option-other-comments-count-refresh"><label for="option-other-comments-count-refresh" data-i18n="option_other_comments_count_refresh"></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-content" id="websocket">
|
||||
|
|
Loading…
Reference in a new issue