search_untube_page.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. {% extends 'base.html' %}
  2. {% load humanize %}
  3. {% load static %}
  4. {% block content %}
  5. <br>
  6. <script>
  7. window.onkeydown = function( event ) {
  8. if ( event.keyCode === 27 ) {
  9. window.close(); // closes current tab
  10. }
  11. };
  12. </script>
  13. <div class="d-flex justify-content-center">
  14. <h1> Search all of UnTube
  15. {% if user.profile.open_search_new_tab %}<h6>Press <kbd>Esc</kbd> to close.</h6>{% endif %}
  16. </h1>
  17. </div>
  18. <div id="search-playlist-form">
  19. <input class="form-control me-lg-2" type="text"
  20. id="untubeSearchBar"
  21. name="search" placeholder="Search UnTube (leave this empty to just filter playlists by tags or filter videos by channels)"
  22. hx-post="{% url 'search_UnTube' %}"
  23. hx-trigger="keyup changed delay:700ms"
  24. hx-target="#untube-searchbar-results"
  25. hx-include="[id='search-playlist-form']"
  26. hx-indicator="#spinner" autofocus>
  27. <br>
  28. <div class="row d-flex justify-content-center">
  29. <div class="col-md-6" id="playlists">
  30. Filter by playlist tags:
  31. <select class="visually-hidden" onchange="triggerSubmit()"
  32. id="choices-playlist-tags" name="playlist-tags" placeholder="Add playlist tags to search within" multiple>
  33. {% for tag in user.playlist_tags.all %}
  34. <option value="{{ tag.name }}" hx-post="{% url 'search_UnTube' %}">{{ tag.name }}</option>
  35. {% endfor %}
  36. </select>
  37. </div>
  38. <div class="col-md-6" id="videos">
  39. Filter by video channels:
  40. <select class="visually-hidden" onchange="triggerSubmit()"
  41. id="choices-channels" name="channel-names" placeholder="Select channels to search within" multiple>
  42. {% for channel in user.profile.get_channels_list %}
  43. <option value="{{ channel }}" hx-post="{% url 'search_UnTube' %}">{{ channel }}</option>
  44. {% endfor %}
  45. </select>
  46. </div>
  47. </div>
  48. <br>
  49. <div class="d-flex justify-content-center">
  50. <div class="form-check me-5">
  51. <input onclick="hideShow()" hx-post="{% url 'search_UnTube' %}"
  52. hx-trigger="click"
  53. hx-target="#untube-searchbar-results"
  54. hx-include="[id='search-playlist-form']"
  55. hx-indicator="#spinner"
  56. class="form-check-input" type="radio" name="search-settings" value="playlists" id="playlists-cb" checked>
  57. <label class="form-check-label " for="playlists-cb">
  58. Playlists
  59. </label>
  60. </div>
  61. <div class="form-check" >
  62. <input onclick="hideShow();" hx-post="{% url 'search_UnTube' %}"
  63. hx-trigger="click"
  64. hx-target="#untube-searchbar-results"
  65. hx-include="[id='search-playlist-form']"
  66. hx-indicator="#spinner"
  67. class="form-check-input" type="radio" name="search-settings" value="videos" id="videos-cb">
  68. <label class="form-check-label" for="videos-cb">
  69. Videos
  70. </label>
  71. </div>
  72. </div>
  73. </div>
  74. <div id="spinner" class="htmx-indicator d-flex justify-content-center p-3">
  75. <div class="spinner-border text-light" role="status">
  76. </div>
  77. </div>
  78. <div id="untube-searchbar-results">
  79. {% if playlists %}
  80. <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
  81. <h1 class="h2">All Playlists <span class="badge bg-primary rounded-pill">{{ playlists.count }}</span></h1>
  82. </div>
  83. <div class="row row-cols-1 row-cols-md-4 g-4">
  84. {% include 'intercooler/playlists.html' %}
  85. </div>
  86. {% endif %}
  87. </div>
  88. <button class="scrollToTopBtn sticky-top">
  89. <i class="fa fa-angle-double-up fa-lg"></i></button>
  90. <script type="application/javascript">
  91. $(document).ready(function(){
  92. videos.style.display = 'none';
  93. // multiple choices select search box
  94. var choicesPlaylistTags = new Choices('#choices-playlist-tags', {
  95. removeItemButton: true,
  96. });
  97. var choicesChannels = new Choices('#choices-channels', {
  98. removeItemButton: true,
  99. });
  100. });
  101. function hideShow() {
  102. var playlistsCB = document.getElementById("playlists-cb");
  103. var videos = document.getElementById("videos");
  104. var playlists = document.getElementById("playlists");
  105. if (playlistsCB.checked) {
  106. videos.style.display = 'none';
  107. playlists.style.display = 'block';
  108. } else {
  109. videos.style.display = 'block';
  110. playlists.style.display = 'none';
  111. }
  112. }
  113. function triggerSubmit() {
  114. var playlistsCB = document.getElementById("playlists-cb");
  115. var videosCB = document.getElementById("videos-cb");
  116. if (playlistsCB.checked) {
  117. playlistsCB.click();
  118. } else {
  119. videosCB.click();
  120. }
  121. }
  122. </script>
  123. {% endblock %}