Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.94 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3.  
  4.   <head>
  5.     <meta charset="utf-8">
  6.     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7.     <meta name="viewport" content="width=device-width, initial-scale=1">
  8.     <title>PUSH JS</title>
  9.     <script
  10.  src="https://code.jquery.com/jquery-3.3.1.min.js"
  11.  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  12.  crossorigin="anonymous"></script>
  13.   </head>
  14.  
  15.   <body>
  16.  
  17.     <div class="container">
  18.  
  19.  
  20.       <form action="" method="POST" role="form">
  21.  
  22.         <div class="form-group">
  23.           <label for="">Título</label>
  24.           <input type="text" class="form-control" id="title" value="Novo Cliente" placeholder="Título do Lembrete" required>
  25.           <label for="">Horário</label>
  26.           <select id="feedback" class="form-control">
  27.             <option value="600000">10 minutos</option>
  28.             <option value="1800000">30 minutos</option>
  29.             <option value="3600000">60 minutos</option>
  30.       </select>
  31.           <label for="">Minha Mensagem de Alerta</label>
  32.           <textarea placeholder="Mensagem do Alerta" id="message" value="Você tem um novo contato no Whatszapp! Clique aqui!" class="form-control" required>Você tem um novo contato no Whatszapp! Clique aqui!</textarea>
  33.         </div>
  34.         <button id="enviar" onclick="myFunction()" type="submit" class="btn btn-success"> <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>Avisa-me!</button>
  35.       </form>
  36.     </div>
  37.     <script type="text/javascript">
  38.       var myFunction = function() {
  39.         confirm('Você tem um cliente para atender!');
  40.       };
  41.       var myImg = "/app/wp-content/uploads/2018/06/iconmonstr-whatsapp-2-240-1.png";
  42.       $("form").submit(function(event) {
  43.         event.preventDefault();
  44.         var options = {
  45.           title: $("#title").val(),
  46.           delay: Number($("#feedback").val()),
  47.           options: {
  48.             body: $("#message").val(),
  49.             icon: myImg,
  50.             lang: 'pt-BR',
  51.             onClick: myFunction
  52.           }
  53.         };
  54.         console.log(options);
  55.         $("#easyNotify").easyNotify(options);
  56.       });
  57.       (function($) {
  58.         $.fn.easyNotify = function(options) {
  59.           var settings = $.extend({
  60.             title: "Notification",
  61.             delay: 0,
  62.             options: {
  63.               body: "",
  64.               icon: "",
  65.               lang: 'pt-BR',
  66.               onClose: "",
  67.               onClick: "",
  68.               onError: ""
  69.             }
  70.           }, options);
  71.           this.init = function() {
  72.             var notify = this;
  73.             if (!("Notification" in window)) {
  74.               alert("This browser does not support desktop notification");
  75.             } else if (Notification.permission === "granted") {
  76.               window.setTimeout(function() {
  77.                 var notification = new Notification(settings.title, settings.options);
  78.                 return notification;
  79.               }, settings.delay)
  80.               notification.onclose = function() {
  81.                 if (typeof settings.options.onClose == 'function') {
  82.                   settings.options.onClose();
  83.                 }
  84.               };
  85.               notification.onclick = function() {
  86.                 if (typeof settings.options.onClick == 'function') {
  87.                   settings.options.onClick();
  88.                 }
  89.               };
  90.               notification.onerror = function() {
  91.                 if (typeof settings.options.onError == 'function') {
  92.                   settings.options.onError();
  93.                 }
  94.               };
  95.             } else if (Notification.permission !== 'denied') {
  96.               Notification.requestPermission(function(permission) {
  97.                 if (permission === "granted") {
  98.                   notify.init();
  99.                 }
  100.               });
  101.             }
  102.           };
  103.           this.init();
  104.           return this;
  105.         };
  106.       }(jQuery));
  107.     </script>
  108.   </body>
  109. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement