Browse Source

Electron integration in notification.js

pull/56/head
Jaussoin Timothée 10 years ago
parent
commit
bcd09cbcad
  1. 35
      app/widgets/Notification/notification.js

35
app/widgets/Notification/notification.js

@ -10,6 +10,7 @@ var Notification = {
document_title : document.title,
notifs_key : '',
favicon : null,
electron : null,
inhibit : function(sec) {
Notification.inhibed = true;
@ -64,10 +65,20 @@ var Notification = {
displayTab : function() {
if(Notification.tab_counter1 == 0 && Notification.tab_counter2 == 0) {
document.title = Notification.document_title;
Notification.favicon.badge(0);
if(Notification.favicon != null)
Notification.favicon.badge(0);
if(Notification.electron != null)
Notification.electron.notification(false);
} else {
Notification.favicon.badge(Notification.tab_counter1 + Notification.tab_counter2);
document.title = '(' + Notification.tab_counter1 + '/' + Notification.tab_counter2 + ') ' + Notification.document_title;
if(Notification.favicon != null)
Notification.favicon.badge(Notification.tab_counter1 + Notification.tab_counter2);
if(Notification.electron != null)
Notification.electron.notification(true);
}
},
current : function(key) {
@ -131,21 +142,31 @@ var Notification = {
}
MovimWebsocket.attach(function() {
Notification.favicon = new Favico({
animation: 'none',
fontStyle: 'normal',
bgColor: '#FF5722'
});
if(typeof Favico != 'undefined') {
Notification.favicon = new Favico({
animation: 'none',
fontStyle: 'normal',
bgColor: '#FF5722'
});
}
if(typeof require !== 'undefined') {
var remote = require('remote');
Notification.electron = remote.getCurrentWindow();
}
Notification.document_title = document.title;
Notification_ajaxGet();
Notification.current(Notification.notifs_key);
});
document.onblur = function() {
console.log('BLUR');
Notification.focused = false;
Notification_ajaxCurrent('blurred');
}
document.onfocus = function() {
console.log('FOCUS');
Notification.focused = true;
Notification.current(Notification.notifs_key);
Notification_ajaxClear(Notification.notifs_key);

Loading…
Cancel
Save