2
0

search_untube_page.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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-10" id="videos">
  67. <div class="row">
  68. <div class="col">
  69. Search in these playlists:
  70. <select class="visually-hidden" onchange="triggerSubmit()"
  71. id="choices-playlists" name="playlist-ids" placeholder="Add playlists to search within" multiple>
  72. {% for playlist in user.profile.get_playlists_list %}
  73. <option value="{{ playlist.playlist_id }}" {% if playlist.playlist_id == playlist_id %}selected{% endif %}>{{ playlist.name }} {% if playlist.user_label %}({{ playlist.user_label }}){% endif %}</option>
  74. {% endfor %}
  75. </select>
  76. </div>
  77. <div class="col">
  78. Filter by video channels:
  79. <select class="visually-hidden" onchange="triggerSubmit()"
  80. id="choices-channels" name="channel-names" placeholder="Select channels to search within" multiple>
  81. {% for channel in user.profile.get_channels_list %}
  82. <option value="{{ channel }}" {% if channel == vid_channel_name %}selected{% endif %}>{{ channel }}</option>
  83. {% endfor %}
  84. </select>
  85. </div>
  86. <div class="col">
  87. <div class="d-flex justify-content-start">
  88. <div>
  89. Video type:
  90. <select onchange="triggerSubmit()" class="form-select mt-1" name="videosType">
  91. <option value="All" {% if item_type == "all" %}selected{% endif %}>All</option>
  92. <option value="Liked" {% if item_type == "liked" %}selected{% endif %}>Liked</option>
  93. <option value="Favorite" {% if item_type == "favorite" %}selected{% endif %}>Favorite</option>
  94. <option value="Watched" {% if item_type == "watched" %}selected{% endif %}>Watched</option>
  95. <option value="Planned to Watch" {% if item_type == "plan-to-watch" %}selected{% endif %}>Planned to Watch</option>
  96. <option value="Unavailable" {% if item_type == "unavailable" %}selected{% endif %}>Unavailable</option>
  97. </select>
  98. </div>
  99. <div class="ms-3">
  100. Sort by:
  101. <select onchange="triggerSubmit()" class="form-select mt-1" name="sortVideosBy">
  102. <option value="recently-accessed" selected>Recently accessed</option>
  103. <option value="video-duration-in-seconds" >Duration</option>
  104. <option value="most-liked" >Most liked</option>
  105. <option value="most-views" >Most views</option>
  106. <option value="date-uploaded" >Date uploaded</option>
  107. </select>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. <div class="d-flex justify-content-center mt-2">
  113. <input class="form-check-input" type="checkbox" name="has-cc" id="mustHaveCCcb" onclick="triggerSubmit()">
  114. <label class="form-check-label ms-2" for="mustHaveCCcb">
  115. Must have CC
  116. </label>
  117. </div>
  118. </div>
  119. <br>
  120. <div class="d-flex justify-content-center mt-3">
  121. <div class="form-check me-5">
  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="playlists" id="playlists-cb" {% if mode == "playlists" %}checked{% endif %}>
  128. <label class="form-check-label " for="playlists-cb">
  129. Playlists
  130. </label>
  131. </div>
  132. <div class="form-check" >
  133. <input onclick="hideShow();" hx-post="{% url 'search_UnTube' %}"
  134. hx-trigger="click"
  135. hx-target="#untube-searchbar-results"
  136. hx-include="[id='search-playlist-form']"
  137. hx-indicator="#spinner"
  138. class="form-check-input" type="radio" name="search-settings" value="videos" id="videos-cb" {% if mode == "videos" %}checked{% endif %}>
  139. <label class="form-check-label" for="videos-cb">
  140. Videos
  141. </label>
  142. </div>
  143. </div>
  144. </div>
  145. <div id="spinner" class="htmx-indicator d-flex justify-content-center p-3">
  146. <div class="spinner-border text-warning" role="status">
  147. </div>
  148. </div>
  149. <div id="untube-searchbar-results">
  150. </div>
  151. <button class="scrollToTopBtn sticky-top">
  152. <i class="fa fa-angle-double-up fa-lg"></i></button>
  153. <script type="application/javascript">
  154. $(document).ready(function(){
  155. {% if mode == "playlists" %}
  156. document.getElementById("videos").style.display = 'none';
  157. {% else %}
  158. document.getElementById("playlists").style.display = 'none';
  159. {% endif %}
  160. // multiple choices select search box
  161. var choicesPlaylistTags = new Choices('#choices-playlist-tags', {
  162. removeItemButton: true,
  163. noChoicesText: "Looks like you haven't created any playlist tags yet!"
  164. });
  165. var choicesChannels = new Choices('#choices-channels', {
  166. removeItemButton: true,
  167. });
  168. var choicesPlaylists = new Choices('#choices-playlists', {
  169. removeItemButton: true,
  170. });
  171. triggerSubmit();
  172. });
  173. function hideShow() {
  174. var playlistsCB = document.getElementById("playlists-cb");
  175. var videos = document.getElementById("videos");
  176. var playlists = document.getElementById("playlists");
  177. if (playlistsCB.checked) {
  178. videos.style.display = 'none';
  179. playlists.style.display = 'block';
  180. } else {
  181. videos.style.display = 'block';
  182. playlists.style.display = 'none';
  183. }
  184. }
  185. function triggerSubmit() {
  186. var playlistsCB = document.getElementById("playlists-cb");
  187. var videosCB = document.getElementById("videos-cb");
  188. if (playlistsCB.checked) {
  189. playlistsCB.click();
  190. } else {
  191. videosCB.click();
  192. }
  193. }
  194. </script>
  195. {% endblock %}