search_untube_page.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 mb-3">
  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" value="{{ query }}"
  21. name="search" placeholder="Search for a specific playlist or a video here (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 onfocus="this.setSelectionRange(this.value.length, this.value.length);">
  27. <br>
  28. <div class="row d-flex justify-content-center">
  29. <div class="col-lg-7" id="playlists">
  30. <div class="row">
  31. <div class="col">
  32. Filter by playlist tags:
  33. <select class="visually-hidden" onchange="triggerSubmit()"
  34. id="choices-playlist-tags" name="playlist-tags" placeholder="Select playlist tags" multiple>
  35. {% for tag in user.playlist_tags.all %}
  36. <option value="{{ tag.name }}" {% if pl_tag == tag.name %}selected{% endif %}>{{ tag.name }}</option>
  37. {% endfor %}
  38. </select>
  39. </div>
  40. <div class="col">
  41. <div class="d-flex justify-content-start">
  42. <div>
  43. Playlist type:
  44. <select onchange="triggerSubmit()" class="form-select mt-1" name="playlistsType">
  45. <option value="All" {% if item_type == "all" %}selected{% endif %}>All</option>
  46. <option value="Favorite" {% if item_type == "favorites" %}selected{% endif %}>Favorites</option>
  47. <option value="Watching" {% if item_type == "watching" %}selected{% endif %}>Watching</option>
  48. <option value="Plan to Watch" {% if item_type == "plan-to-watch" %}selected{% endif %}>Plan to Watch</option>
  49. <option value="Owned" {% if item_type == "user-owned" %}selected{% endif %}>Owned</option>
  50. <option value="Imported" {% if item_type == "imported" %}selected{% endif %}>Imported</option>
  51. <option value="Mix" {% if item_type == "yt-mix" %}selected{% endif %}>YT Mix</option>
  52. </select>
  53. </div>
  54. <div class="ms-3">
  55. Sort by:
  56. <select onchange="triggerSubmit()" class="form-select mt-1" name="sortPlaylistsBy">
  57. <option value="recently-accessed" selected>Recently accessed</option>
  58. <option value="playlist-duration-in-seconds" >Duration</option>
  59. <option value="video-count" >Number of videos</option>
  60. </select>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. <div class="col-lg-8" id="videos">
  67. <div class="row">
  68. <div class="col">
  69. Filter by video channels:
  70. <select class="visually-hidden" onchange="triggerSubmit()"
  71. id="choices-channels" name="channel-names" placeholder="Select channels to search within" multiple>
  72. {% for channel in user.profile.get_channels_list %}
  73. <option value="{{ channel }}" {% if channel == vid_channel_name %}selected{% endif %}>{{ channel }}</option>
  74. {% endfor %}
  75. </select>
  76. </div>
  77. <div class="col">
  78. <div class="d-flex justify-content-start">
  79. <div>
  80. Video type:
  81. <select onchange="triggerSubmit()" class="form-select mt-1" name="videosType">
  82. <option value="All" {% if item_type == "all" %}selected{% endif %}>All</option>
  83. <option value="Favorite" {% if item_type == "favorite" %}selected{% endif %}>Favorite</option>
  84. <option value="Watched" {% if item_type == "watched" %}selected{% endif %}>Watched</option>
  85. <option value="Unavailable" {% if item_type == "unavailable" %}selected{% endif %}>Unavailable</option>
  86. </select>
  87. </div>
  88. <div class="ms-3">
  89. Sort by:
  90. <select onchange="triggerSubmit()" class="form-select mt-1" name="sortVideosBy">
  91. <option value="recently-accessed" selected>Recently accessed</option>
  92. <option value="video-duration-in-seconds" >Duration</option>
  93. <option value="most-liked" >Most liked</option>
  94. <option value="most-views" >Most views</option>
  95. <option value="date-uploaded" >Date uploaded</option>
  96. </select>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. <div class="d-flex justify-content-center mt-2">
  102. <input class="form-check-input" type="checkbox" name="has-cc" id="mustHaveCCcb" onclick="triggerSubmit()">
  103. <label class="form-check-label ms-2" for="mustHaveCCcb">
  104. Must have CC
  105. </label>
  106. </div>
  107. </div>
  108. <br>
  109. <div class="d-flex justify-content-center mt-3">
  110. <div class="form-check me-5">
  111. <input onclick="hideShow()" hx-post="{% url 'search_UnTube' %}"
  112. hx-trigger="click"
  113. hx-target="#untube-searchbar-results"
  114. hx-include="[id='search-playlist-form']"
  115. hx-indicator="#spinner"
  116. class="form-check-input" type="radio" name="search-settings" value="playlists" id="playlists-cb" {% if mode == "playlists" %}checked{% endif %}>
  117. <label class="form-check-label " for="playlists-cb">
  118. Playlists
  119. </label>
  120. </div>
  121. <div class="form-check" >
  122. <input onclick="hideShow();" hx-post="{% url 'search_UnTube' %}"
  123. hx-trigger="click"
  124. hx-target="#untube-searchbar-results"
  125. hx-include="[id='search-playlist-form']"
  126. hx-indicator="#spinner"
  127. class="form-check-input" type="radio" name="search-settings" value="videos" id="videos-cb" {% if mode == "videos" %}checked{% endif %}>
  128. <label class="form-check-label" for="videos-cb">
  129. Videos
  130. </label>
  131. </div>
  132. </div>
  133. </div>
  134. <div id="spinner" class="htmx-indicator d-flex justify-content-center p-3">
  135. <div class="spinner-border text-warning" role="status">
  136. </div>
  137. </div>
  138. <div id="untube-searchbar-results">
  139. </div>
  140. <button class="scrollToTopBtn sticky-top">
  141. <i class="fa fa-angle-double-up fa-lg"></i></button>
  142. <script type="application/javascript">
  143. $(document).ready(function(){
  144. {% if mode == "playlists" %}
  145. document.getElementById("videos").style.display = 'none';
  146. {% else %}
  147. document.getElementById("playlists").style.display = 'none';
  148. {% endif %}
  149. // multiple choices select search box
  150. var choicesPlaylistTags = new Choices('#choices-playlist-tags', {
  151. removeItemButton: true,
  152. noChoicesText: "Looks like you haven't created any playlist tags yet!"
  153. });
  154. var choicesChannels = new Choices('#choices-channels', {
  155. removeItemButton: true,
  156. });
  157. triggerSubmit();
  158. });
  159. function hideShow() {
  160. var playlistsCB = document.getElementById("playlists-cb");
  161. var videos = document.getElementById("videos");
  162. var playlists = document.getElementById("playlists");
  163. if (playlistsCB.checked) {
  164. videos.style.display = 'none';
  165. playlists.style.display = 'block';
  166. } else {
  167. videos.style.display = 'block';
  168. playlists.style.display = 'none';
  169. }
  170. }
  171. function triggerSubmit() {
  172. var playlistsCB = document.getElementById("playlists-cb");
  173. var videosCB = document.getElementById("videos-cb");
  174. if (playlistsCB.checked) {
  175. playlistsCB.click();
  176. } else {
  177. videosCB.click();
  178. }
  179. }
  180. </script>
  181. {% endblock %}