<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>{% block title %}OpenCVE{% endblock %}</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.ico') }}">

    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/bootstrap.min.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/font-awesome.min.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/spectrum.min.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/select2.min.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/AdminLTE.min.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/skin-blue.min.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/custom.css') }}">

    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue skin-opencve sidebar-mini sidebar-collapse">

<div class="wrapper">

    <header class="main-header">

        <a href="{{ url_for('main.home') }}" class="logo">
            <span class="logo-mini"><img src="{{ url_for('static', filename='img/logo_white.png') }}"
                                         alt="Logo"/></span>
            <span class="logo-lg"><img src="{{ url_for('static', filename='img/logo_white.png') }}" alt="Logo"/></span>
        </a>

        <nav class="navbar navbar-static-top">
            <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>

            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    {% if current_user.is_authenticated %}
                    <li class="dropdown user user-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <img src="{{ current_user.email | gravatar(size=30) }}" class="user-image" alt="User Image">
                            <span class="hidden-xs">{{ current_user.username }}</span>
                        </a>
                        <ul class="dropdown-menu">
                            <li class="user-header">
                                <img src="{{ current_user.email | gravatar(size=160) }}" class="img-circle"
                                     alt="{{ current_user.username }}">
                                <p>{{ current_user.username }}</p>
                            </li>
                            <li class="user-footer">
                                <div class="pull-left">
                                    <a href="{{ url_for('main.subscriptions') }}" class="btn btn-default btn-flat">Account</a>
                                    {% if current_user.admin %}
                                    <a href="{{ url_for('admin.index') }}" class="btn btn-default btn-flat">Admin</a>
                                    {% endif %}
                                </div>
                                <div class="pull-right">
                                    <a href="{{ url_for('user.logout') }}" class="btn btn-default btn-flat">Sign out</a>
                                </div>
                            </li>
                        </ul>
                    </li>
                    {% else %}
                    <li>
                        <a href="{{ url_for('user.login') }}">Sign in</a>
                    </li>
                    <li>
                        <a href="{{ url_for('user.register') }}">Register</a>
                    </li>
                    {% endif %}
                </ul>
            </div>
        </nav>
    </header>

    <aside class="main-sidebar">

        <section class="sidebar">

            {% if current_user.is_authenticated %}
            <div class="user-panel">
                <div class="pull-left image">
                    <img src="{{ current_user.email | gravatar(size=160) }}" class="img-circle"
                         alt="{{ current_user.username }}">
                </div>
                <div class="pull-left info">
                    <p>{{ current_user.username }}</p>
                    <a href="{{ url_for('main.subscriptions') }}"><i class="fa fa-circle text-success"></i> Online</a>
                </div>
            </div>
            {% endif %}

            <ul class="sidebar-menu" data-widget="tree">
                {% if current_user.is_authenticated %}
                <li {% if is_active(
                "main.home") %}class="active"{% endif %}><a href="{{ url_for('main.home') }}"><i class="fa fa-home"></i>
                <span>Dashboard</span></a></li>
                <li {% if is_active(
                "main.reports,main.report") %}class="active"{% endif %}><a href="{{ url_for('main.reports') }}"><i
                    class="fa fa-list-alt"></i> <span>Reports</span></a></li>
                {% endif %}
                <li {% if is_active(
                "main.cves,main.cve") %}class="active"{% endif %}><a href="{{ url_for('main.cves') }}"><i
                    class="fa fa-shield"></i> <span>Vulnerabilities (CVE)</span></a></li>
                <li {% if is_active(
                "main.vendors,main.products") %}class="active"{% endif %}><a href="{{ url_for('main.vendors') }}"><i
                    class="fa fa-tags"></i> <span> Vendors & Products (CPE)</span></a></li>
                <li {% if is_active(
                "main.cwes") %}class="active"{% endif %}><a href="{{ url_for('main.cwes') }}"><i
                    class="fa fa-sitemap"></i> <span> Categories (CWE)</span></a></li>
            </ul>

        </section>
    </aside>

    <div class="content-wrapper">
        {% if request.endpoint not in ['main.notifications', 'main.tags', 'main.edit_tag', 'main.settings'] %}
        {% include 'flash_messages.html' %}
        {% endif %}
        {% block content %}{% endblock %}
    </div>

    <footer class="main-footer">
        <strong>Copyright &copy; 2021 OpenCVE.</strong>
    </footer>

</div>

<script src="{{ url_for('static', filename='js/jquery.min.js') }}" type="text/javascript"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}" type="text/javascript"></script>
<script src="{{ url_for('static', filename='js/adminlte.min.js') }}" type="text/javascript"></script>
<script src="{{ url_for('static', filename='js/jquery.rainbowJSON.js') }}" type="text/javascript"></script>
<script src="{{ url_for('static', filename='js/spectrum.min.js') }}" type="text/javascript"></script>
<script src="{{ url_for('static', filename='js/select2.full.min.js') }}" type="text/javascript"></script>
<script src="{{ url_for('static', filename='js/custom.js') }}" type="text/javascript"></script>
{% if config.INCLUDE_ANALYTICS %}
{% include 'analytics.html' %}
{% endif %}

<script>
  function getContrastedColor(str){
    rgb = str.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
    var yiq = ((rgb[1]*299)+(rgb[2]*587)+(rgb[3]*114))/1000;
    return (yiq >= 128) ? '#000' : '#fff';
  }

  $(document).ready(function () {
    function setTagsColor() {
        $(".label-tag").each(function(i) {
            var fontColor = getContrastedColor($(this).css("background-color"));
            $(this).css('color', fontColor);
        });
    }
    $('.sidebar-menu').tree();
    $('[data-toggle="popover"]').popover();
    $('[data-toggle="tooltip"]').tooltip();
    $('.codejson').rainbowJSON({
        maxElements: 0,
        maxDepth: 0,
        json: null,
        bgColor: '#F5FAFF'
    });
    $('.config-toggle').click(function(){
      var conf = $(this).attr("id");
      $("#" + conf + "-table").toggle();
      if ( $("#" + conf + "-table").is(":hidden") ) {
        $(this).text("show");
      } else {
        $(this).text("hide");
      }
    });
    $('#config-all-toggle').click(function(){
      $('.table-configuration').toggle();
    });
    $('#genNew').click(function() {
        var color = '#' + Math.floor(Math.random()*16777215).toString(16);
        $('.preview-tag').css('background-color', color);
        $(".colorpicker").spectrum("set", color);
        setTagsColor();
        return false;
    });
    $(".colorpicker").spectrum({
        preferredFormat: "hex",
        showPalette: true,
        togglePaletteMoreText: 'more',
        togglePaletteLessText: 'less',
        palette: [
            ["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],
            ["#f00","#f90","#ff0","#0f0","#0ff","#00f","#90f","#f0f"],
            ["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"],
            ["#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#9fc5e8","#b4a7d6","#d5a6bd"],
            ["#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6fa8dc","#8e7cc3","#c27ba0"],
            ["#c00","#e69138","#f1c232","#6aa84f","#45818e","#3d85c6","#674ea7","#a64d79"],
            ["#900","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"],
            ["#600","#783f04","#7f6000","#274e13","#0c343d","#073763","#20124d","#4c1130"]
        ]
    });
    $(".colorpicker").on('move.spectrum', function(e, tinycolor) {
        $('.preview-tag').css('background-color', tinycolor.toHexString());
        setTagsColor();
    });
    setTagsColor();
    $('.select2').select2({allowClear: true});
    $('#select2-tags').val($('.select2').data("values")).trigger('change');
  });

</script>
</body>
</html>
