Browse Source

Improved favicon on notify

master
Igor Zhukov 11 years ago
parent
commit
dc1c2aa9c8
  1. 4
      app/index.html
  2. 16
      app/js/services.js

4
app/index.html

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css"/>
<link rel="stylesheet" href="vendor/jquery.nanoscroller/nanoscroller.css"/>
<link rel="stylesheet" href="css/app.css?11"/>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<meta property="og:title" content="Webogram">
<meta property="og:url" content="http://zhukov.github.io/webogram/">
@ -52,7 +52,7 @@ @@ -52,7 +52,7 @@
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/app.js?8"></script>
<script type="text/javascript" src="js/services.js?11"></script>
<script type="text/javascript" src="js/services.js?12"></script>
<script type="text/javascript" src="js/controllers.js?16"></script>
<script type="text/javascript" src="js/filters.js?3"></script>
<script type="text/javascript" src="js/directives.js?10"></script>

16
app/js/services.js

@ -1926,10 +1926,10 @@ angular.module('myApp.services', []) @@ -1926,10 +1926,10 @@ angular.module('myApp.services', [])
var notificationIndex = 0;
var notificationsCount = 0;
var peerSettings = {};
var faviconEl = $('link[rel="icon"]');
var faviconBackupEl = $('link[rel="icon"]'),
faviconNewEl = $('<link rel="icon" href="favicon_unread.ico" type="image/x-icon" />');
var titleBackup = document.title,
faviconBackup = faviconEl.attr('href'),
titlePromise;
$rootScope.$watch('idle.isIDLE', function (newVal) {
@ -1939,20 +1939,22 @@ angular.module('myApp.services', []) @@ -1939,20 +1939,22 @@ angular.module('myApp.services', [])
if (!newVal) {
notificationsCount = 0;
document.title = titleBackup;
faviconEl.attr('href', faviconBackup);
$('link[rel="icon"]').replaceWith(faviconBackupEl);
notificationsClear();
} else {
titleBackup = document.title;
titlePromise = $interval(function () {
var time = +new Date();
// console.log('check title', notificationsCount, time % 2000 > 1000);
if (!notificationsCount || time % 2000 > 1000) {
document.title = titleBackup;
faviconEl.attr('href', faviconBackup);
$('link[rel="icon"]').replaceWith(faviconBackupEl);
} else {
document.title = notificationsCount + ' notifications';
faviconEl.attr('href', 'favicon_unread.ico');
document.title = notificationsCount > 1
? (notificationsCount + ' notifications')
: '1 notification';
$('link[rel="icon"]').replaceWith(faviconNewEl);
}
}, 1000);
}

Loading…
Cancel
Save