{% from "macros.html" import image -%}
<!DOCTYPE html>
<html lang="en">
  <head>
    {% block head %}
      <title>{% block title %}{{ title or "New Zealand ORCID Hub"}}{% endblock %}</title>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="description" content="NZ ORCID Hub"/>
      <meta name="author" content="">
      <link rel="apple-touch-icon" sizes="57x57" href="{{image('apple-icon-57x57.png')}}">
      <link rel="apple-touch-icon" sizes="60x60" href="{{image('apple-icon-60x60.png')}}">
      <link rel="apple-touch-icon" sizes="72x72" href="{{image('apple-icon-72x72.png')}}">
      <link rel="apple-touch-icon" sizes="76x76" href="{{image('apple-icon-76x76.png')}}">
      <link rel="apple-touch-icon" sizes="114x114" href="{{image('apple-icon-114x114.png')}}">
      <link rel="apple-touch-icon" sizes="120x120" href="{{image('apple-icon-120x120.png')}}">
      <link rel="apple-touch-icon" sizes="144x144" href="{{image('apple-icon-144x144.png')}}">
      <link rel="apple-touch-icon" sizes="152x152" href="{{image('apple-icon-152x152.png')}}">
      <link rel="apple-touch-icon" sizes="180x180" href="{{image('apple-icon-180x180.png')}}">
      <link rel="icon" href="{{image('favicon.ico')}}?v=3">
      <link rel="icon" type="image/png" sizes="192x192"  href="{{image('android-icon-192x192.png')}}">
      <link rel="icon" type="image/png" sizes="32x32" href="{{image('favicon-32x32.png')}}?v=3">
      <link rel="icon" type="image/png" sizes="96x96" href="{{image('favicon-96x96.png')}}?v=3">
      <link rel="icon" type="image/png" sizes="16x16" href="{{image('favicon-16x16.png')}}?v=3">
      <link rel="manifest" href="{{url_for('static', filename='manifest.json')}}">
      <meta name="msapplication-TileColor" content="#ffffff">
      <meta name="msapplication-TileImage" content="{{image('ms-icon-144x144.png')}}">
      <meta name="theme-color" content="#ffffff">
      <meta name="keywords" content="ORCID HUB,New Zealand,NZ,orcid"/>
      <meta name="viewport" content="width=device-width, initial-scale=1">


      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
      <link rel="stylesheet" href="https://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css">
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">
      <link href="{{url_for('static', filename='css/sticky-footer.css')}}" rel="stylesheet">
      <link href="{{url_for('static', filename='css/style.css')}}" rel="stylesheet">
    {% endblock %}
  </head>
  <body>
    {% include 'header.html' %}
    <div class="container" style="padding-bottom:160px">
      {% block content %}{% endblock %}
    </div>
    {% include 'footer.html' %}

    {% block scripts %}
      <!-- javascript at the bottom for fast page loading -->
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
      <!-- script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/i18n/defaults-*.min.js"></script -->
      {% block footer %}{% endblock %}

      <script>
// Catch exception when closing dialog with <esc> key
// and prevent accidental deletions.
function safeConfirm(msg) {
  try {
    var isconfirmed = confirm(msg);
    if (isconfirmed == true) {
      return true;
    }
    else {
      return false;
    }
  }
  catch(err) {
    return false;
  }
}

$(document).ready(function(){
  $("time").each(function () {
     var el = $(this);
     var dt = moment.utc(el.attr("datetime")).local();
     el.html(dt.format(el.data("format") || "YYYY[&#8209;]MM[&#8209;]DD[&nbsp;]HH:mm"));
  });
  $('[data-toggle="tooltip"]').tooltip();
  $("#{{request.endpoint}}").addClass("active");
  // Google Analytics
  (function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,"script","https://www.google-analytics.com/analytics.js","ga");

  ga("create", "{{config.GA_TRACKING_ID}}", "auto");
  ga("set", "userid", "{{current_user.email}}");
  ga("send", "pageview");
  {% block ga_event %}<!-- Placeholder for Google Analytics events -->{% endblock %}
});
{% if request.args.get("logout") %}
  $.ajax({url: '{{config.ORCID_BASE_URL}}' + 'userStatus.json?logUserOut=true', dataType: 'jsonp'});
{% endif %}
      </script>
    {% endblock %}
  </body>
</html>
