{% load static %}
{% with domain="http://127.0.0.1:8000/" %}
<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="keywords" content="youtube, playlists, videos, delete videos, delete playlists, delete multiple videos, move multiple videos, merge playlists, video manager, playlist manager, youtube playlists, untube, google">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="UnTube is a simple Youtube playlist manager. Modify and keep track of your YouTube playlists with ease.">
        <meta name="author" content="Mohammed Abu Bakar Khan">
        <title>UnTube</title>

        <style type="text/css">
            body {
                background: linear-gradient(-45deg, #B2A3FF, #84bcf3, #AE876B, #B0E7AE);
                //background: linear-gradient(-45deg, #0645a4, #2480cd, #84bcf3, #b7d6f7);
                //background: linear-gradient(-45deg, #AE876B, #ABA27B, #A7BC8A, #A3D69A);
                background-size: 400% 400%;
                animation: gradient 10s ease infinite;
                }

            @keyframes gradient {
                0% {
                    background-position: 0% 50%;
                }
                50% {
                    background-position: 100% 50%;
                }
                100% {
                    background-position: 0% 50%;
                }
            }


            #btn-back-to-top {
              position: fixed;
              bottom: 20px;
              right: 20px;
              display: none;
            }

            .big-checkbox {width: 30px; height: 30px;}

        </style>

        <link href="https://fonts.googleapis.com/css2?family=Fredoka+One&family=Open+Sans&display=swap" rel="stylesheet">

        <link href="{% static 'fontawesome-free-5.15.3-web/css/all.min.css' %}" rel="stylesheet">
        <link href="{% static 'bootstrap5.0.1/css/bootstrap.min.css' %}" rel="stylesheet">
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/bbbootstrap/libraries@main/choices.min.css">


    </head>
    <body class="text-dark" style="font-family: 'Fredoka One', monospace; filter: contrast(80%);">


        {% if user.profile.show_import_page %}
            <meta http-equiv="refresh" content="0;url={{ domain }}import/init" />
        {% endif %}
        <nav class="navbar navbar-expand-lg navbar-light" id="navbar">
            <div class="container-fluid">
                <a class="navbar-brand" href="{% url 'home' %}"><h3><kbd>UnTube</kbd></h3></a>
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 me-auto mb-2 mb-lg-0">
                        <li class="nav-item">
                            <a class="nav-link" aria-current="page" href="{% url 'home' %}">Dashboard</a>
                        </li>

                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="libraryDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                                Library
                            </a>
                            <ul class="dropdown-menu" aria-labelledby="libraryDropdown">
                                <li><a class="dropdown-item" href="{% url 'all_playlists' 'home' %}">Playlists</a></li>
                                <li><a class="dropdown-item" href="{% url 'all_videos' 'home' %}">Videos</a></li>
                            </ul>
                        </li>
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="quickViewDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                                Quick View
                            </a>
                            <ul class="dropdown-menu" aria-labelledby="quickViewDropdown">
                                <li><a class="dropdown-item" href="{% url 'all_playlists' 'favorites' %}">Favorites</a></li>
                                <li><a class="dropdown-item" href="{% url 'all_playlists' 'watching' %}">Watching</a></li>
                                <li><a class="dropdown-item" href="{% url 'all_playlists' 'plan-to-watch' %}">Plan to Watch</a></li>
                                <li><a class="dropdown-item" href="{% url 'all_playlists' 'user-owned' %}">Your YT Playlists</a></li>
                                <li><a class="dropdown-item" href="{% url 'all_playlists' 'imported' %}">Imported</a></li>
                                <li><hr class="dropdown-divider"></li>
                                <li><a class="dropdown-item" href="{% url 'all_playlists' 'all' %}">View all</a></li>
                            </ul>
                        </li>

                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'manage_playlists' %}">Manage</a>
                        </li>

                        <!--
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'settings' %}">Settings</a>
                        </li>
                        -->
                    </ul>


                    <div class="navbar-nav justify-content-end">
                        <!--
                        <input class="form-control border border-secondary bg-dark text-white-50 me-lg-2 bg-dark mb-1" id="unTubeSearchBar" type="text" placeholder="Search UnTube">
                        -->
                        <a class="nav-link btn-lg me-1 mt-1" href="{% url 'search' %}" {% if user.profile.open_search_new_tab %}target="_blank"{% endif %}>
                            <i class="fas fa-search"></i>
                        </a>

                        <a href="{% url 'profile' %}" class="mt-1">
                        <img src="https://robohash.org/{{ user.username }}.png?set=set{{ user.profile.robohash_set }}" alt="{{ user.username }}" class="border border-3 border-primary rounded-circle me-2" width="42" height="42">
                        </a>

                    </div>
                    <a class="btn btn-outline-danger" href="{% url 'log_out' %}">
                      Log out
                    </a>
                </div>
            </div>
        </nav>



        <div class="container-fluid text-dark">

            <div class="row">
                <main class="ms-lg-auto px-lg-5">
                {% block content %}
                {% endblock %}
                </main>
            </div>
        </div>

        <br>


        <script src="{% static 'htmx/htmx.min.js' %}" type="application/javascript"></script>
        <script src="{% static 'clipboard.js/clipboard.min.js' %}" type="application/javascript"></script>
        <script src="{% static 'jquery3.6.0/js/jquery-3.6.0.min.js' %}" type="application/javascript"></script>
        <script src="{% static 'bootstrap5.0.1/js/bootstrap.bundle.min.js' %}" type="application/javascript"></script>
        <script src="https://cdn.jsdelivr.net/gh/bbbootstrap/libraries@main/choices.min.js"></script>
        <!-- <script src="{% static 'htmx/extensions/class-tools.js' %}" type="application/javascript"></script> -->


        <script type="application/javascript">
            $(document).ready(function(){

                var multipleCancelButton = new Choices('#choices-multiple-remove-button', {
                removeItemButton: true,
                });

            });

            function triggerSubmit() {
                var startsWithCB = document.getElementById("starts-with-cb");
                var containsCB = document.getElementById("contains-cb");

                if (startsWithCB.checked) {
                    startsWithCB.click();
                } else {
                    containsCB.click();
                }
            }


            document.body.addEventListener('htmx:configRequest', (event) => {
            event.detail.headers['X-CSRFToken'] = '{{ csrf_token }}';
          })

            // window.onbeforeunload = function() {
        //return "Dude, are you sure you want to leave? Think of the kittens!";
            //}

                 var moveCopyBtn = document.getElementById('move-copy-vids-btn');
            var moveCopyCollapse = document.getElementById('moveItemsToCollapse');
            var bsMoveCopyCollapse = new bootstrap.Collapse(moveCopyCollapse, {
                toggle: false
            });
            var deleteBtn = document.getElementById('delete-vids-btn');
            var deleteCollapse = document.getElementById('deleteItemsCollapse');
            var bsDeleteCollapse = new bootstrap.Collapse(deleteCollapse, {
                toggle: false
            });


            document.getElementById('manageBtn').addEventListener('click', function () {
                bsMoveCopyCollapse.hide();
                bsDeleteCollapse.hide();
            });
            moveCopyCollapse.addEventListener('show.bs.collapse', function () {
                    bsDeleteCollapse.hide();
            });
            deleteCollapse.addEventListener('show.bs.collapse', function () {
                    bsMoveCopyCollapse.hide();
            });

            <!-- end -->


            document.getElementById('select-all-btn').onclick = function() {
                document.getElementById('select-all-btn').style.display = "none";
                document.getElementById('deselect-all-btn').style.display = "block";

                var checkboxes = document.getElementsByClassName('video-checkboxes');
                for (var checkbox of checkboxes) {
                    checkbox.checked = true;
                }
            }
            document.getElementById('deselect-all-btn').onclick = function() {
                document.getElementById('deselect-all-btn').style.display = "none";
                document.getElementById('select-all-btn').style.display = "block";

                var checkboxes = document.getElementsByClassName('video-checkboxes');
                for (var checkbox of checkboxes) {
                    checkbox.checked = false;
                }
            }

             function row1_hide() {
                 document.getElementById("row1").style.display = "none";
                 var checkboxes = document.getElementsByClassName('video-checkboxes'); //Cache the collection here, so that even a new element added with the same class later we can avoid querying this again by using the cached collection.
                 for(var i=0, len=checkboxes.length; i<len; i++)
                {
                    checkboxes[i].style.display = "block";
                }
                 document.getElementById("row2").style.display = "block";
             }

             function row1_show() {
                 document.getElementById("row1").style.display = "block";
                 var checkboxes = document.getElementsByClassName('video-checkboxes'); //Cache the collection here, so that even a new element added with the same class later we can avoid querying this again by using the cached collection.
                 for(var i=0, len=checkboxes.length; i<len; i++)
                {
                    checkboxes[i].style.display = "none";
                }
                document.getElementById("row2").style.display = "none";
             }

             function select_all_checkboxes(source) {
              checkboxes = document.getElementsByClassName('big-checkbox');
              for(var i=0, n=checkboxes.length;i<n;i++) {
                checkboxes[i].checked = source.checked;
              }
            }


            var clipboard = new ClipboardJS('.copy-btn');


            //Get the button
            let mybutton = document.getElementById("btn-back-to-top");

            // When the user scrolls down 20px from the top of the document, show the button
            window.onscroll = function () {
              scrollFunction();
            };

            function scrollFunction() {
              if (
                document.body.scrollTop > 150 ||
                document.documentElement.scrollTop > 150
              ) {
                mybutton.style.display = "block";
              } else {
                mybutton.style.display = "none";
              }
            }
            // When the user clicks on the button, scroll to the top of the document
            mybutton.addEventListener("click", backToTop);

            function backToTop() {
              document.body.scrollTop = 0;
              document.documentElement.scrollTop = 0;
            }

        </script>


        <!--
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js" integrity="sha384-zNy6FEbO50N+Cg5wap8IKA4M/ZnLJgzc6w2NqACZaK0u0FXfOWRRJOnQtpZun8ha" crossorigin="anonymous"></script>
        -->

    </body>
</html>
{% endwith %}