<!DOCTYPE html>
<html lang="it">
<head>
  {% block head %}
  <title>{{ title }} - ALLERTA sistema gestionale {{ owner }}</title>
  <link href="{{ urlsoftware }}/resources/images/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
  <meta name="viewport" content="user-scalable=no, initial-scale=1">
  <meta name="google" content="notranslate">
  <meta name="robots" content="none">
  <link rel="manifest" href="manifest.webmanifest">
  {% if delete_caches %}
  <script>
  //from https://stackoverflow.com/a/57149239
  if ('caches' in window) {
    console.log("Deleting caches...");
    caches.keys()
    .then(function(keyList) {
      Promise.all(keyList.map(function(key) {
        caches.delete(key);
        console.log("deleted cache: "+key);
      }));
    });
  }
  /*{% if not delete_service_workers %}*/
  location.href="?";
  /*{% endif %}*/
  </script>
  {% endif %}
  {% if delete_service_workers %}
  <script>
  //from https://stackoverflow.com/a/47515250
  if(window.navigator && navigator.serviceWorker) {
    console.log("UnRegistering service workers...");
    navigator.serviceWorker.getRegistrations()
    .then(function(registrations) {
      for(let registration of registrations) {
        console.log("deleted service worker:");
        console.log(registration);
        registration.unregister();
      }
    });
    location.href="?";
  }
  /*{% if delete_service_workers_and_disable %}*/
  document.cookie = "disableServiceWorkerInstallation=1";
  /*{% endif %}*/
  </script>
  {% endif %}
  <script src="{{ urlsoftware }}/resources/dist/{{ resource('main.js') }}"></script>
  <script>$.fn.loading.defaults.message = "{{ 'Loading...'|t }}";</script>
  {% if enable_technical_support and technical_support_open %}
  <!-- Smartsupp Live Chat script -->
  <script type='text/javascript'>
    var _smartsupp = _smartsupp || {};
    _smartsupp.key = '{{ technical_support_key }}';
    _smartsupp.ratingEnabled = true; // default value : false
    _smartsupp.ratingComment = true; // default value : false
    window.smartsupp || (function (d) {
      var s, c, o = smartsupp = function () {
        o._.push(arguments)
      };
      o._ = [];
      s = d.getElementsByTagName('script')[0];
      c = d.createElement('script');
      c.type = 'text/javascript';
      c.charset = 'utf-8';
      c.async = true;
      c.src = 'https://www.smartsuppchat.com/loader.js?';
      s.parentNode.insertBefore(c, s);
    })(document);
  </script>
  <script>
    // basic info
    smartsupp('email', '');
    smartsupp('name', '{{ user.name }}');
    smartsupp('recording:disable', false);
    // extra info
    smartsupp('variables', {
      name: {
        label: 'name user ',
        value: '{{ user.name }}'
      },
      Admin: {
        label: 'Admin',
        value: '{{ user.full_viewer }}'
      }
    });
  </script>
  {% endif %}
  {% endblock %}
  {% if enable_debug_bar %}{{ debug_bar_head|raw }}{% endif %}
</head>
<body>
{% if show_menu %}
  {% block menu %}
  <!-- Menu -->
  <div class="topnav" id="topNavBar">
    <a href="{{ urlsoftware }}list.php" class="active">{{ 'Availability List'|t }}</a>
    <a href="{{ urlsoftware }}services.php">{{ 'Services'|t }}</a>
    <a href="{{ urlsoftware }}trainings.php">{{ 'Trainings'|t }}</a>
    <a href="{{ urlsoftware }}log.php">{{ 'Logs'|t }}</a>
    <a {# href="{{ urlsoftware }}graphics.php" #}>{{ 'Graphics'|t }}</a>
    {% if enable_technical_support %}<a href="javascript:void(0);"
      onclick="chat()">{{ 'Technical Support' }}</a>{% endif %}
    <a style="float: right;" id="logout">{{ 'Hi, %s.'|t|format(user.name) }} <b
        onclick="location.href='{{ urlsoftware }}logout.php';">{{ 'Logout'|t }}</b></a>
    <a href="javascript:void(0);" class="icon" onclick="menu()">☰</a>
  </div>
  <!-- /Menu -->
  {% endblock %}
{% endif %}
  <div class="alert alert-danger m-3" id="offline_alert" style="display: none" role="alert">
    <b>{{ 'You are offline'|t }}.</b> {{ 'Last update'|t }}: <p style="display: inline" id="offline_update"></p>
  </div>
  <!-- Content -->
  <div id="content">
{% block pjax_content %}
{% if pjax_requested %}<title>{{ title }} - ALLERTA sistema gestionale {{ owner }}</title>{% endif %}
{% block content %}{% endblock %}
{% endblock %}
  </div>
  <!-- /Content -->
  {% if enable_debug_bar %}{{ debug_bar|raw }}{% endif %}
{% if show_footer %}
  {% block footer %}
  <!-- Footer -->
  <div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2);">
    Allerta-VVF, software libero realizzato per {{ owner }}.<br>
    <p style="margin-bottom: 0" id="frontend_version">Frontend versione </p>
  </div>
  <!-- /Footer -->
  {% endblock %}
{% endif %}
</body>
</html>