Advertisement
HenX

Notification

Jan 17th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.     var SUZCT = SUZCT || {};
  3.     SUZCT.NotificationManager = SUZCT.NotificationManager || {};
  4.    
  5.     document.addEventListener('DOMContentLoaded', function () {
  6.         if (Notification.permission !== "granted")
  7.             Notification.requestPermission();
  8.     });        
  9.  
  10.     $(document).ready(function () {  
  11.         SUZCT.NotificationManager.Hub = $.connection.notificationsHub;                    
  12.        
  13.         $.connection.hub.start();
  14.      
  15.         SUZCT.NotificationManager.Hub.client.SendNotification = function (message) {
  16.             if (Notification.permission !== "granted") {
  17.                 Notification.requestPermission();                
  18.             }
  19.             else {
  20.                 var notification = new Notification('SÚZ Český Těšín', {
  21.                     icon: '@Href("~/Images/logo_margin.png")',
  22.                     body: message,
  23.                 });
  24.                
  25.                 notification.onclick = function () {
  26.                     window.open("http://www.suzct.cz");
  27.                 };
  28.  
  29.  
  30.             };
  31.         };
  32.     });
  33. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement