Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var focus = true;
- window.onfocus = function() {focus = true;};
- window.onblur = function() {focus = false;};
- MPP.client.ws.onmessage = function(message) {
- if (typeof message.data === "string") {
- message = JSON.parse(message.data);
- if (message[0].m == "a") {
- if (Notification.permission == "granted") {
- if (!focus) {
- new Notification("Message", {body: message[0].a});
- }
- } else if (Notification !== "denied") {
- Notification.requestPermission(function (permission) {
- if (permission === "granted") {
- new Notification("Now I will annoy you.", {body: "It is true"});
- }
- });
- }
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement