-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathonMessage.js
More file actions
48 lines (44 loc) · 1.36 KB
/
Copy pathonMessage.js
File metadata and controls
48 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
if(lingr) {
if(lingr.getCookie('popup')) {
if(webkitNotifications.checkPermission() == 0) {
var target = $('popupNotify').down('a');
target.removeClassName('disabled').addClassName('enabled');
target.title = 'turn off popup notification';
} else {
lingr.clearCookie('popup');
}
}
lingr.ui.togglePopup = function() {
var target = $('popupNotify').down('a');
if (target.hasClassName('disabled')) {
if( webkitNotifications.checkPermission() != 0) {
webkitNotifications.requestPermission();
}
if(webkitNotifications.checkPermission() == 0) {
target.removeClassName('disabled').addClassName('enabled');
target.title = 'turn off popup notification';
lingr.setCookie('popup','on');
}
} else {
target.removeClassName('enabled').addClassName('disabled');
target.title = 'turn on popup notification';
lingr.clearCookie('popup');
}
};
lingr.ui._insertMessage = lingr.ui.insertMessage;
lingr.ui.insertMessage = function(msg, bulk) {
notifyMessage(msg);
this._insertMessage(msg, bulk);
}
function notifyMessage(msg) {
if(lingr.getCookie("popup") && webkitNotifications.checkPermission() == 0) {
var notification = webkitNotifications.createNotification(
msg.icon_url, msg.room, msg.nickname + ": " + msg.text
);
notification.show();
setTimeout(function() {
notification.cancel();
}, 4000);
}
}
}