{% load static %}
{% load raven %}

<!DOCTYPE html>
<html
        dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}"
        xml:lang="{% firstof LANGUAGE_CODE 'en' %}"
        lang="{% firstof LANGUAGE_CODE 'en' %}">
<head>
    <title>{% block title %}{{page_title|striptags}}{% endblock %} | Rig Information Gathering System</title>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="icon" type="image/png" href="{% static 'imgs/pyrigs-avatar.png' %}">
    <link rel="apple-touch-icon" href="{% static 'imgs/pyrigs-avatar.png' %}">
    <link href='{% static 'fonts/OPENSANS-REGULAR.TTF' %}'>

    <link rel="stylesheet" type="text/css" href="{% static 'css/screen.css' %}">
    {% block css %}
    {% endblock %}

    <script src="{% static 'js/jquery.js' %}"></script>
    <script src="{% static 'js/popper.js' %}"></script>
    <script src="{% static 'js/raven.js' %}"></script>
    <script>Raven.config('{% sentry_public_dsn %}').install()</script>
    {% block preload_js %}
    {% endblock %}

    {% block extra-head %}{% endblock %}
</head>

<body>
<a class="skip-link" href='#main'>Skip to content</a>
{% include "analytics.html" %}
{% block navbar %}
<nav class="navbar navbar-expand-lg navbar-dark bg-dark" role="navigation">
  <div class="container">
      {% block titleheader %}
      {% endblock %}
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav">
            {% block titleelements %}
            {% endblock %}
        </ul>
        <ul class="navbar-nav ml-auto">
            {% block titleelements_right %}
            {% endblock %}
        </ul>
      </div>
  </div>
</nav>
{% endblock %}
<div class="container py-4" id="main">
    {% block content-header %}
        {% if error %}
            <div class="error">{{ error }}</div>{% endif %}
        {% if info %}
            <div class="info">{{ info }}</div>{% endif %}
        {% if messages %}
            {% for message in messages %}
                <div class="alert alert-{{ message.level_tag }} alert-dismissible" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    {{ message }}
                </div>
            {% endfor %}
        {% endif %}
    {% endblock %}
    {% if page_title and not request.is_ajax %}
    <h2>{{page_title|safe}}</h2>
    {% endif %}
    {% block content %}{% endblock %}
</div>

<div class="modal fade" id="modal" role="dialog" tabindex=-1></div>

<script>
    Date.prototype.getISOString = function () {
        var yyyy = this.getFullYear().toString();
        var mm = (this.getMonth() + 1).toString(); // getMonth() is zero-based
        var dd = this.getDate().toString();
        return yyyy + '-' + (mm[1] ? mm : "0" + mm[0]) + '-' + (dd[1] ? dd : "0" + dd[0]); // padding
    };
</script>
<script src="{% static 'js/util.js' %}"></script>
<script src="{% static 'js/alert.js' %}"></script>
<script src="{% static 'js/collapse.js' %}"></script>
<script>
    $('.navbar-collapse').addClass('collapse')
</script>
<script src="{% static 'js/dropdown.js' %}"></script>
<script src="{% static 'js/modal.js' %}"></script>
<script src="{% static 'js/konami.js' %}"></script>
<script src="{% static 'js/all.js' %}"></script> <!---FontAwesome--->
<script>
    jQuery(document).ready(function () {
        jQuery(document).on('click', '.modal-href', function (e) {
            $link = jQuery(this);
            // Anti modal inception
            if ($link.parents('#modal').length == 0) {
                e.preventDefault();
                modaltarget = $link.data('target');
                modalobject = "";
                jQuery('#modal').load($link.attr('href'), function (e) {
                    jQuery('#modal').modal();
                });
            }
        });


        var easter_egg = new Konami();
        easter_egg.code = function () {
            var s = document.createElement('script');
            s.type = 'text/javascript';
            document.body.appendChild(s);
            s.src = '{% static "js/asteroids.min.js"%}';
            ga('send', 'event', 'easter_egg', 'activated');
        }
        easter_egg.load();
    });
</script>
<script src="{% static 'js/dark-mode-switch.min.js' %}"></script>
<script>
    document.body.addEventListener('keydown', function(e) {
        if(e.keyCode == 13 && (e.metaKey || e.ctrlKey)) {
            var target = e.target;
            if(target.form) {
                target.form.submit();
            }
        }
    });
</script>
{% block js %}
{% endblock %}
</body>
</html>
