<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>
<?php $browserpush_welcome = Zend_Registry::isRegistered('browserpush_welcome') ? Zend_Registry::get('browserpush_welcome') : null; ?>
<?php include APPLICATION_PATH .  '/application/modules/Browserpush/views/scripts/dismiss_message.tpl';
?>
<?php if($browserpush_welcome) { ?>
<div class="settings">
  <div class='settings'>
    <?php echo $this->form->render($this); ?>
  </div>
</div>
<?php } ?>
<?php $file = Engine_Api::_()->getApi('settings', 'core')->getSetting('browserpush.welcomeicon', ''); ?>
<script type="text/javascript">
  <?php if (empty($file)) { ?>
    en4.core.runonce.add(function() {
      if (scriptJquery('#cat_icon_preview-wrapper'))
        scriptJquery('#cat_icon_preview-wrapper').hide();
    });
  <?php } ?>
  //Show choose image 
  function showReadImage(input, id) {
    var url = input.value;
    var ext = url.substring(url.lastIndexOf('.') + 1).toLowerCase();
    if (input.files && input.files[0] && (ext == "png" || ext == "jpeg" || ext == "jpg" || ext == 'PNG' || ext == 'JPEG' || ext == 'JPG' || ext == 'webp')) {
      var reader = new FileReader();
      reader.onload = function(e) {
        document.getElementById(id + '-wrapper').style.display = 'flex';
        scriptJquery('#' + id).attr('src', e.target.result);
      }
      document.getElementById(id + '-wrapper').style.display = 'flex';
      reader.readAsDataURL(input.files[0]);
    }
  }

  function welcomeSettings(value) {
    if (value == 0) {
      document.getElementById('browserpush_welcometitle-wrapper').style.display = 'none';
      document.getElementById('browserpush_welcomedescription-wrapper').style.display = 'none';
      document.getElementById('browserpush_welcomelink-wrapper').style.display = 'none';
      document.getElementById('icon-wrapper').style.display = 'none';
      if (document.getElementById('cat_icon_preview-wrapper'))
        document.getElementById('cat_icon_preview-wrapper').style.display = 'none';
      if (document.getElementById('remove_icon_icon-wrapper'))
        document.getElementById('remove_icon_icon-wrapper').style.display = 'none';
    } else {
      document.getElementById('browserpush_welcometitle-wrapper').style.display = 'flex';
      document.getElementById('browserpush_welcomedescription-wrapper').style.display = 'flex';
      document.getElementById('browserpush_welcomelink-wrapper').style.display = 'flex';
      document.getElementById('icon-wrapper').style.display = 'flex';
      if (document.getElementById('cat_icon_preview-wrapper'))
        document.getElementById('cat_icon_preview-wrapper').style.display = 'flex';
      if (document.getElementById('remove_icon_icon-wrapper'))
        document.getElementById('remove_icon_icon-wrapper').style.display = 'flex';
    }
  }
  welcomeSettings(<?php echo Engine_Api::_()->getApi('settings', 'core')->getSetting('browserpush.welcomeenable', '1'); ?>);
</script>