search_untube_page.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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"
  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">
  30. <select class="visually-hidden" onchange="triggerSubmit()"
  31. id="choices-multiple-remove-button" name="playlist-tags" placeholder="Add playlist tags to search within" multiple>
  32. {% for tag in user.playlist_tags.all %}
  33. <option value="{{ tag.name }}" hx-post="{% url 'search_UnTube' %}">{{ tag.name }}</option>
  34. {% endfor %}
  35. </select>
  36. </div>
  37. </div>
  38. <br>
  39. <div class="d-flex justify-content-center">
  40. <div class="form-check me-5">
  41. <input hx-post="{% url 'search_UnTube' %}"
  42. hx-trigger="click"
  43. hx-target="#untube-searchbar-results"
  44. hx-include="[id='search-playlist-form']"
  45. hx-indicator="#spinner"
  46. class="form-check-input" type="radio" name="search-settings" value="starts-with" id="starts-with-cb" checked>
  47. <label class="form-check-label" for="starts-with-cb">
  48. Starts with
  49. </label>
  50. </div>
  51. <div class="form-check">
  52. <input hx-post="{% url 'search_UnTube' %}"
  53. hx-trigger="click"
  54. hx-target="#untube-searchbar-results"
  55. hx-include="[id='search-playlist-form']"
  56. hx-indicator="#spinner"
  57. class="form-check-input" type="radio" name="search-settings" value="contains" id="contains-cb">
  58. <label class="form-check-label" for="contains-cb">
  59. Contains
  60. </label>
  61. </div>
  62. </div>
  63. </div>
  64. <div id="spinner" class="htmx-indicator d-flex justify-content-center p-3">
  65. <div class="spinner-border text-light" role="status">
  66. </div>
  67. </div>
  68. <div id="untube-searchbar-results">
  69. {% if playlists %}
  70. <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
  71. <h1 class="h2">All Playlists <span class="badge bg-primary rounded-pill">{{ playlists.count }}</span></h1>
  72. </div>
  73. {% include 'intercooler/playlists.html' %}
  74. {% endif %}
  75. </div>
  76. <button class="scrollToTopBtn sticky-top">
  77. <i class="fa fa-angle-double-up fa-lg"></i></button>
  78. <script type="application/javascript">
  79. $(document).ready(function(){
  80. // multiple choices select search box
  81. var multipleCancelButton = new Choices('#choices-multiple-remove-button', {
  82. removeItemButton: true,
  83. });
  84. });
  85. function triggerSubmit() {
  86. var startsWithCB = document.getElementById("starts-with-cb");
  87. var containsCB = document.getElementById("contains-cb");
  88. if (startsWithCB.checked) {
  89. startsWithCB.click();
  90. } else {
  91. containsCB.click();
  92. }
  93. }
  94. </script>
  95. {% endblock %}