Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. function notifyMe() {
  2. // Let's check if the browser supports notifications
  3. if (!("Notification" in window)) {
  4. alert("This browser does not support desktop notification");
  5. }
  6.  
  7. // Let's check if the user is okay to get some notification
  8. else if (Notification.permission === "granted") {
  9. // If it's okay let's create a notification
  10. var notification = new Notification("Hi there!");
  11. }
  12.  
  13. // Otherwise, we need to ask the user for permission
  14. // Note, Chrome does not implement the permission static property
  15. // So we have to check for NOT 'denied' instead of 'default'
  16. else if (Notification.permission !== 'denied') {
  17. Notification.requestPermission(function (permission) {
  18.  
  19. // Whatever the user answers, we make sure we store the information
  20. if(!('permission' in Notification)) {
  21. Notification.permission = permission;
  22. }
  23.  
  24. // If the user is okay, let's create a notification
  25. if (permission === "granted") {
  26. var notification = new Notification("Hi there!");
  27. }
  28. });
  29. }
  30.  
  31. // At last, if the user already denied any notification, and you
  32. // want to be respectful there is no need to bother him any more.
  33. }
  34. notifyMe();
  35. TIMER = setInterval(function() { if ($("#goldenCookie").style.display != "none") { notifyMe(); } }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement