@ -769,8 +769,7 @@ function init_notifications() {
// </notification>
// </notification>
// <notifs html5>
// <notifs html5>
var notifs _html5 _permission = 'denied' ,
var notifs _html5 _permission = 'denied' ;
notifs _html5 _shown = false ;
function notifs _html5 _is _supported ( ) {
function notifs _html5 _is _supported ( ) {
return window . Notification !== undefined ;
return window . Notification !== undefined ;
@ -783,7 +782,7 @@ function notifs_html5_ask_permission() {
}
}
function notifs _html5 _show ( nb ) {
function notifs _html5 _show ( nb ) {
if ( notifs _html5 _permission !== "granted" || notifs _html5 _shown ) {
if ( notifs _html5 _permission !== "granted" ) {
return
return
}
}
@ -795,8 +794,6 @@ function notifs_html5_show(nb) {
notification . onclick = function ( ) {
notification . onclick = function ( ) {
window . location . reload ( ) ;
window . location . reload ( ) ;
}
}
notifs _html5 _shown = true ;
}
}
function init _notifs _html5 ( ) {
function init _notifs _html5 ( ) {
@ -810,19 +807,24 @@ function init_notifs_html5() {
function refreshUnreads ( ) {
function refreshUnreads ( ) {
$ . getJSON ( './?c=javascript&a=nbUnreadsPerFeed' ) . done ( function ( data ) {
$ . getJSON ( './?c=javascript&a=nbUnreadsPerFeed' ) . done ( function ( data ) {
var isAll = $ ( '.category.all > .active' ) . length > 0 ;
var isAll = $ ( '.category.all > .active' ) . length > 0 ,
new _articles = false ;
$ . each ( data , function ( feed _id , nbUnreads ) {
$ . each ( data , function ( feed _id , nbUnreads ) {
feed _id = 'f_' + feed _id ;
feed _id = 'f_' + feed _id ;
var elem = $ ( '#' + feed _id + '>.feed' ) . get ( 0 ) ,
var elem = $ ( '#' + feed _id + '>.feed' ) . get ( 0 ) ,
feed _unreads = elem ? str2int ( elem . getAttribute ( 'data-unread' ) ) : 0 ;
feed _unreads = elem ? str2int ( elem . getAttribute ( 'data-unread' ) ) : 0 ;
if ( ( incUnreadsFeed ( null , feed _id , nbUnreads - feed _unreads ) || isAll ) && //Update of current view?
if ( ( incUnreadsFeed ( null , feed _id , nbUnreads - feed _unreads ) || isAll ) && //Update of current view?
( nbUnreads - feed _unreads > 0 ) ) {
( nbUnreads - feed _unreads > 0 ) ) {
$ ( '#new-article' ) . show ( ) ;
$ ( '#new-article' ) . show ( ) ;
new _articles = true ;
} ;
} ;
} ) ;
} ) ;
var nb _unreads = str2int ( $ ( '.category.all>a' ) . attr ( 'data-unread' ) ) ;
var nb _unreads = str2int ( $ ( '.category.all>a' ) . attr ( 'data-unread' ) ) ;
if ( nb _unreads > 0 ) {
if ( nb _unreads > 0 && new _articles ) {
faviconNbUnread ( nb _unreads ) ;
faviconNbUnread ( nb _unreads ) ;
notifs _html5 _show ( nb _unreads ) ;
notifs _html5 _show ( nb _unreads ) ;
}
}