var status = "";

if ('Notification' in window) {
  status = Notification.permission;
}

function requestPermission() {
  if (!('Notification' in window)) {
    alert('Notification API not supported!');
    return;
  }
  else{
     
  }
  Notification.requestPermission(function (result) {
     
    status = result;
    if(status =='granted'){
        document.getElementById('addEditForm:addEditButtonId').click();
    }
  });
}

function nonPersistentNotification(args) {
  if (!('Notification' in window)) {
    return;
  }
  try {
    if (args !== 'undefined' && args.notificationSize > 0) {
      var msg = new SpeechSynthesisUtterance();
      msg.text = "New Booking Request ";
      window.speechSynthesis.speak(msg);
      var i;
      for (i = 0; i < args.notificationSize; i++) {
        var notification = new Notification(args.notification[i]);
      }
    }
  } catch (err) {
  }
}

function persistentNotification() {
  if (!('Notification' in window) || !('ServiceWorkerRegistration' in window)) {
    alert('Persistent Notification API not supported!');
    return;
  }
  
  try {
    navigator.serviceWorker.getRegistration()
      .then((reg) => reg.showNotification("Hi there - persistent!"))
      .catch((err) => alert('Service Worker registration error: ' + err));
  } catch (err) {
    alert('Notification API error: ' + err);
  }
}
