{% load static %}
<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
        <meta name="generator" content="Hugo 0.83.1">
        <title>UnTube</title>

        <style type="text/css">
            #btn-back-to-top {
              position: fixed;
              bottom: 20px;
              right: 20px;
              display: none;
                z-index: 4;
            }

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

        </style>

          <!--
          <script src="https://unpkg.com/htmx.org@1.4.1"></script>
          <script src="https://unpkg.com/htmx.org/dist/ext/class-tools.js"></script>
          <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>

          -->

        <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">

    </head>
    <body class="bg-dark text-white"  style="font-family: 'Fredoka One',fantasy; filter: contrast(80%);">
        <nav class="navbar navbar-expand-lg navbar-dark bg-dark sticky-top">
            <div class="container-fluid">
                <a class="navbar-brand" href="{% url 'home' %}"><h3>UnTube</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">
                            <a class="nav-link" href="{% url 'all_playlists' 'home' %}">Library</a>
                        </li>
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                                Quick View
                            </a>
                            <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
                                <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 id="unTubeSearchBtn" class="nav-link btn-lg me-2" data-bs-toggle="modal" data-bs-target="#unTubeSearchBarResultsModal">
                            <i class="fas fa-search"></i>
                        </a>

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

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


        </main>

      </div>

    </div>


        <button
        type="button"
        class="btn btn-danger btn-floating btn-lg"
        id="btn-back-to-top"
        >
            ▲
        </button>

        <br>

                    <!-- Button trigger modal -->

        <!-- Modal -->
        <div class="modal fade bg-dark" id="unTubeSearchBarResultsModal" tabindex="-1" aria-labelledby="unTubeSearchBarResultsModalLabel" aria-hidden="true">
          <div class="modal-dialog modal-fullscreen modal-dialog-scrollable bg-dark">
            <div class="modal-content bg-dark">
              <div class="modal-body bg-dark">
              <div id="untube-searchbar-results">

                <div class="d-flex justify-content-center">
                   <h1> Search all of UnTube                     <h6>Press <code>Esc</code> to close.</h6>
</h1>
                </div>
                <input class="form-control me-lg-2 bg-dark text-white" id="unTubeSearchBarModal" type="text"
                       name="search" placeholder="Search UnTube"
                       hx-post="{% url 'search_UnTube' %}"
                       hx-trigger="keyup changed delay:1s"
                       hx-target="#untube-searchbar-results"
                       hx-include="[id='searchbar-radio-form']"
                       hx-indicator=".htmx-indicator">
                  <br>
                  <div id="searchbar-radio-form">
                    <div class="d-flex justify-content-center">
                     <div class="form-check me-5">
                      <input class="form-check-input" type="radio" name="search-settings" value="starts-with" id="starts-with-cb" checked>
                      <label class="form-check-label" for="starts-with-cb">
                        Starts with
                      </label>
                    </div>
                     <div class="form-check">
                      <input class="form-check-input" type="radio" name="search-settings" value="contains" id="contains-cb">
                      <label class="form-check-label" for="contains-cb">
                        Contains
                      </label>
                    </div>
                  </div>
                  </div>
                </div>
                <div id="spinner" class="htmx-indicator d-flex justify-content-center">
                <div class="spinner-border text-light" role="status">
                </div>
                </div>
              </div>

            </div>
          </div>
        </div>


        <script src="{% static 'htmx/htmx.min.js' %}"></script>
        <script src="{% static 'clipboard.js/clipboard.min.js' %}"></script>
        <script src="{% static 'jquery3.6.0/js/jquery-3.6.0.min.js' %}"></script>
        <script src="{% static 'bootstrap5.0.1/js/bootstrap.bundle.js' %}"></script>
        <script src="{% static 'htmx/extensions/class-tools.js' %}"></script>


        <script>

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



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

            <!-- for view_playlist.html -->
            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 () {
                    moveCopyBtn.classList = "btn btn-success";
                    bsDeleteCollapse.hide();

            });
            moveCopyCollapse.addEventListener('hide.bs.collapse', function () {
                    moveCopyBtn.classList = "btn btn-outline-success";
            });
            deleteCollapse.addEventListener('show.bs.collapse', function () {
                    deleteBtn.classList = "btn btn-danger";
                    bsMoveCopyCollapse.hide();
            });
            deleteCollapse.addEventListener('hide.bs.collapse', function () {
                    deleteBtn.classList = "btn btn-outline-danger";
            });

            <!-- end -->


             // Get the input field
            var input = document.getElementById("unTubeSearchBar");

            // Execute a function when the user releases a key on the keyboard
            input.addEventListener("click", function(event) {

                document.getElementById("unTubeSearchBtn").click();
                document.getElementById("unTubeSearchBarModal").focus();

            });

            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;
              }
            }

            //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 > 550 ||
                document.documentElement.scrollTop > 550
              ) {
                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>