view_playlist.html 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  1. {% extends 'base.html' %}
  2. {% load humanize %}
  3. {% load static %}
  4. {% block content %}
  5. <script src="{% static 'htmx/extensions/class-tools.js' %}" type="application/javascript"></script>
  6. <div id="view_playlist">
  7. {% if not_imported_LL %}
  8. <div hx-get="/import/liked-videos-playlist" hx-trigger="load" hx-swap="outerHTML">
  9. <div class="alert alert-dismissible fade show" role="alert" style="background-color: cadetblue">
  10. <div class="d-flex justify-content-center flex-column mt-4 mb-3 ms-2" id="loading-sign" >
  11. <div class="d-flex justify-content-center">
  12. <img src="/static/svg-loaders/spinning-circles.svg" width="40" height="40">
  13. <h5 class="mt-2 ms-2 text-black">Importing your Liked Videos playlist into UnTube, do not refresh this page!
  14. </h5>
  15. </div>
  16. <div class="d-flex justify-content-center mt-1">
  17. <h6>(this might take a while if you have more than 700 liked videos!)</h6>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. {% else %}
  23. {% if playlist.has_playlist_changed %}
  24. <div hx-get="{% url 'update_playlist' playlist.playlist_id 'auto' %}" hx-trigger="load" hx-swap="outerHTML">
  25. <div class="d-flex justify-content-center mt-4 mb-3" id="loading-sign">
  26. <img src="{% static 'svg-loaders/circles.svg' %}" width="40" height="40" style="filter: invert(0%) sepia(18%) saturate(7468%) hue-rotate(241deg) brightness(84%) contrast(101%);">
  27. <h5 class="mt-2 ms-2">Refreshing playlist '{{ playlist.name }}', please wait!</h5>
  28. </div>
  29. </div>
  30. {% else %}
  31. <div class="sticky-top mb-3" style="top: 0.5rem;">
  32. {% if not playlist.is_yt_mix %}
  33. {% if user.profile.auto_check_for_updates %}
  34. {% if playlist.auto_check_for_updates %}
  35. <div hx-get="{% url 'update_playlist' playlist.playlist_id 'checkforupdates' %}" hx-trigger="load" hx-swap="outerHTML" id="checkforupdates">
  36. <div class="alert alert-info alert-dismissible fade show" role="alert">
  37. Checking playlist for updates...
  38. </div>
  39. </div>
  40. {% endif %}
  41. {% endif %}
  42. {% endif %}
  43. {% if playlist.marked_as == "watching" %}
  44. <div id="playlist-watch-message">
  45. {% include 'intercooler/playlist_watch_message.html' %}
  46. </div>
  47. {% endif %}
  48. </div>
  49. <div class="alert alert-dark alert-dismissible fade show" role="alert" id="user-label-alert" style="display:none;">
  50. <form method="post" action="{% url 'add_playlist_user_label' playlist.playlist_id %}" class="d-flex justify-content-center">
  51. {% csrf_token %}
  52. <span class="mt-2 me-1">Enter an optional label to identify this playlist with:</span>
  53. <input class="form-control w-25 me-2" type="text" placeholder="Enter here" name="user_label" value="{{ playlist.user_label }}" aria-label="user label">
  54. <button type="submit" class="btn btn-primary">Save</button>
  55. </form>
  56. <button type="button" class="btn-close mt-2 me-2" onclick='document.getElementById("user-label-alert").style.display = "none";' aria-label="Close"></button>
  57. </div>
  58. <div class="card text-white" style="max-width: 100%; background-color: #1A4464;">
  59. <div class="row g-0">
  60. <div class="col-md-4 p-3">
  61. <img class="img-fluid rounded-3" src="{{ playlist_items.0.video.thumbnail_url }}" style="max-width:100%; height: auto; object-fit: cover;">
  62. </div>
  63. <div class="col-md-8">
  64. <div class="card-body">
  65. <div class="d-flex justify-content-between">
  66. <h2 class="card-title text-white">
  67. <a href="https://www.youtube.com/playlist?list={{ playlist.playlist_id }}" target="_blank" style="color: white; text-decoration: none">{{ playlist.name }}</a>
  68. <button class="btn btn-light btn-sm ms-2" onclick='document.getElementById("user-label-alert").style.display = "block";'>
  69. <i class="fas fa-pencil-alt" aria-hidden="true"></i>
  70. </button>
  71. <br><small class="h4">{% if playlist.user_label %}a.k.a <span style="border-bottom: 3px #ffffff dashed;"> {{ playlist.user_label }}</span>{% endif %}</small>
  72. </h2>
  73. <h4>
  74. <span id="notice-div">
  75. {% if playlist.marked_as != "none" %}
  76. <span class="badge bg-success text-white" >
  77. {% if playlist.marked_as == "watching" %}
  78. <i class="fas fa-fire-alt me-1"></i>
  79. {% elif playlist.marked_as == "plan-to-watch"%}
  80. <i class="fas fa-flag me-1"></i>
  81. {% endif %}
  82. {{ playlist.marked_as }}
  83. </span>
  84. {% endif %}
  85. </span>
  86. <span id="">
  87. <!--
  88. <span class="badge bg-dark">
  89. <i class="fas fa-map-pin"></i>
  90. </span>
  91. -->
  92. </span>
  93. </h4>
  94. </div>
  95. <h6>by <a href="{% url 'search' %}?mode=videos&channel={{ playlist.channel_name }}" style="text-decoration: none; color: white"><span style="border-bottom: 3px #e35959 dashed;">{{ playlist.channel_name }}</span></a></h6>
  96. <p class="card-text">
  97. {% if playlist.description %}
  98. <h5 class="overflow-auto" style="max-height: 350px;">
  99. {{ playlist.description|linebreaksbr|urlize }}
  100. </h5>
  101. {% else %}
  102. <h5>No description</h5>
  103. {% endif %}
  104. </p>
  105. <h6 class="h6 text-uppercase overflow-auto">
  106. <span class="badge bg-light text-black-50">{% if playlist.is_user_owned %}OWNED{% else %}IMPORTED{% endif %}</span>
  107. <span class="badge bg-light text-black-50">{{ playlist.video_count }} VIDEOS</span>
  108. <a data-bs-toggle="collapse" href="#playlistDurationCollapse" role="button" aria-expanded="false" aria-controls="playlistDurationCollapse">
  109. <span class="badge bg-light text-black-50">{{ playlist.playlist_duration }}</span>
  110. </a>
  111. <div class="collapse" id="playlistDurationCollapse">
  112. <div class="card card-body bg-transparent text-white text-capitalize border border-3 mt-2 mb-2 border-light">
  113. <div hx-get="{% url 'playlist_completion_times' playlist.playlist_id %}"
  114. hx-trigger="revealed"
  115. hx-swap="outerHTML">
  116. </div>
  117. </div>
  118. </div>
  119. <span class="badge bg-light text-black-50">{% if playlist.is_private_on_yt %}PRIVATE{% else %}PUBLIC{% endif %}</span>
  120. {% if playlist.is_yt_mix %}<span class="badge bg-light text-black-50">YT MIX</span>{% endif %}
  121. {% if playlist.has_unavailable_videos %}
  122. <span class="badge bg-light text-black-50">
  123. {% if playlist.get_watchable_videos_count == 0 %}
  124. ALL
  125. {% else %}
  126. {{ playlist.get_unavailable_videos_count }}
  127. {% endif %}
  128. VIDEOS ARE UNAVAILABLE
  129. </span>
  130. {% endif %}
  131. {% if playlist.has_duplicate_videos %}
  132. <span class="badge bg-light text-black-50">{{ playlist.get_duplicate_videos_count }} DUPLICATE VIDEOS</span>
  133. {% endif %}
  134. <a data-bs-toggle="collapse" href="#channelVidsChartCollapse" role="button" aria-expanded="false" aria-controls="channelVidsChartCollapse">
  135. <span class="badge bg-light text-black-50">{{ playlist.get_channels_list.0 }} channels</span>
  136. </a>
  137. <div class="collapse" id="channelVidsChartCollapse">
  138. <div class="card card-body bg-transparent text-white border border-3 mt-2 border-light">
  139. <canvas id="channel-videos-chart" data-url="{% url 'channel_videos_distribution' playlist.playlist_id %}"></canvas>
  140. </div>
  141. </div>
  142. </h6>
  143. <h6 class="h6 pt-1">
  144. Tags:
  145. <span class="text-uppercase" >
  146. <span id="playlist-tags">
  147. {% for tag in playlist_tags %}
  148. <span id="tag-{{ tag.name|slugify }}" class="mb-2">
  149. <span class="badge rounded-pill bg-info mb-lg-2">
  150. <a href="{% url 'tagged_playlists' tag.name %}" style="text-decoration: none; color: #114f7f">{{ tag.name }} </a>
  151. <a class="ms-1" hx-post="{% url 'remove_playlist_tag' playlist.playlist_id tag.name %}" hx-trigger="click" hx-target="#tag-{{ tag.name|slugify }}"><i class="fas fa-times-circle"></i></a>
  152. </span>
  153. </span>
  154. {% endfor %}
  155. </span>
  156. <a data-bs-toggle="collapse" href="#addTagsCollapse" role="button" aria-expanded="false" aria-controls="addTagsCollapse">
  157. <span class="badge rounded-pill bg-warning mb-lg-2"><i class="fas fa-plus"></i></span>
  158. </a>
  159. </span>
  160. <div class="collapse" id="addTagsCollapse">
  161. <div class="card card-body bg-dark text-white border border-4 mt-1 border-warning">
  162. <h5>Add a tag to this playlist</h5>
  163. {% if unused_tags %}
  164. <div class="d-flex justify-content-start mt-2">
  165. <select class="form-select w-50 bg-dark text-white border border-secondary" name="playlistTag" hx-get="{% url 'get_unused_playlist_tags' playlist.playlist_id %}" hx-trigger="click" hx-target="#unused-playlist-tags">
  166. <option selected>Pick from existing unused tags</option>
  167. <span id="unused-playlist-tags">
  168. {% for tag in unused_tags %}
  169. <option value="{{ tag.name }}">{{ tag.name }}</option>
  170. {% endfor %}
  171. </span>
  172. </select>
  173. <div class="btn-group ms-2">
  174. <button type="button" class="btn btn-warning" hx-post="{% url 'add_playlist_tag' playlist.playlist_id %}" hx-trigger="click" hx-include="[name='playlistTag']" hx-target="this">Add Tag</button>
  175. </div>
  176. </div>
  177. <div class="d-flex justify-content-start mt-3 mb-2">
  178. - OR -
  179. </div>
  180. {% endif %}
  181. <div class="d-flex justify-content-start mt-2">
  182. <input class="form-control w-50 bg-dark text-white border border-secondary" placeholder="Enter a new tag name here" name="createTagField">
  183. <div class="btn-group ms-2">
  184. <button type="button" class="btn btn-warning" hx-post="{% url 'create_playlist_tag' playlist.playlist_id %}" hx-trigger="click" hx-include="[name='createTagField']" hx-target="this">Create & Add Tag</button>
  185. </div>
  186. </div>
  187. </div>
  188. </div>
  189. </h6>
  190. <p class="card-text text-white-50"><small>Last updated {{ playlist.updated_at|naturalday }}</small> &bullet; <small>{{ playlist.num_of_accesses }} clicks </small></p>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. <br>
  196. <div id="row1">
  197. <div class="d-flex bd-highlight mb-1">
  198. <div class="me-auto bd-highlight">
  199. <div class="btn-toolbar mb-2 mb-md-0">
  200. <!--
  201. <div class="btn-group me-2">
  202. <button type="button" class="btn {% if playlist.view_in_grid_mode %}btn-info {% else %}btn-outline-info{% endif %}">Grid</button>
  203. <button type="button" class="btn {% if not playlist.view_in_grid_mode %}btn-info {% else %}btn-outline-info{% endif %}">List</button>
  204. </div>
  205. -->
  206. <div class="btn-group me-2 mb-2">
  207. <button type="button" class="btn btn-warning dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
  208. Mark As
  209. </button>
  210. <ul class="dropdown-menu">
  211. <li><button class="dropdown-item" hx-get="{% url 'mark_playlist_as' playlist.playlist_id 'none' %}" hx-trigger="click" hx-target="#notice-div">None</button></li>
  212. <li><button class="dropdown-item" hx-get="{% url 'mark_playlist_as' playlist.playlist_id 'watching' %}" hx-trigger="click" hx-target="#notice-div">Watching</button></li>
  213. <li><button class="dropdown-item" hx-get="{% url 'mark_playlist_as' playlist.playlist_id 'plan-to-watch' %}" hx-trigger="click" hx-target="#notice-div">Plan to Watch</button></li>
  214. </ul>
  215. </div>
  216. {% if playlist_items.count != 0 %}
  217. <div class="btn-group me-2 mb-2">
  218. <button type="button" class="btn btn-success dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
  219. Sort By
  220. </button>
  221. <ul class="dropdown-menu">
  222. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'all' %}" hx-trigger="click" hx-target="#videos-div">All</button></li>
  223. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'favorites' %}" hx-trigger="click" hx-target="#videos-div">Favorites</button></li>
  224. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'popularity' %}" hx-trigger="click" hx-target="#videos-div">Popularity</button></li>
  225. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'date-published' %}" hx-trigger="click" hx-target="#videos-div">Date Published</button></li>
  226. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'views' %}" hx-trigger="click" hx-target="#videos-div">Views</button></li>
  227. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'has-cc' %}" hx-trigger="click" hx-target="#videos-div">Has CC</button></li>
  228. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'duration' %}" hx-trigger="click" hx-target="#videos-div">Duration</button></li>
  229. <li><hr class="dropdown-divider"></li>
  230. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'new-updates' %}" hx-trigger="click" hx-target="#videos-div">Updates</button></li>
  231. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'unavailable-videos' %}" hx-trigger="click" hx-target="#videos-div">Unavailable</button></li>
  232. </ul>
  233. </div>
  234. <div class="btn-group me-2 mb-2">
  235. {% with channels=playlist.get_channels_list %}
  236. <button type="button" class="btn btn-info dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
  237. {{ channels.0 }} Channels
  238. </button>
  239. <ul class="dropdown-menu">
  240. {% for channel in channels.1 %}
  241. <li><a class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'channel' %}" hx-vals='{"channel-name": "{{ channel }}"}' hx-trigger="click" hx-target="#videos-div">{{ channel }}</a></li>
  242. {% endfor %}
  243. </ul>
  244. {% endwith %}
  245. </div>
  246. {% endif %}
  247. </div>
  248. </div>
  249. <div class="bd-highlight">
  250. <div class="btn-toolbar mb-2 mb-md-0 overflow-auto">
  251. <div class="btn-group me-2 mb-2">
  252. <a hx-get="{% url 'update_playlist' playlist.playlist_id 'manual' %}" hx-target="#view_playlist" class="btn btn-secondary">
  253. <i class="fas fa-sync"></i>
  254. </a>
  255. </div>
  256. {% if playlist.video_count > 1 %}
  257. <div class="btn-group me-2 mb-2">
  258. <a href="{% url 'playlist_open_random_video' playlist.playlist_id %}" class="btn btn-danger">
  259. Open a Random Video
  260. </a>
  261. </div>
  262. {% endif %}
  263. <div class="btn-group me-2 mb-2">
  264. <button class="btn btn-dark" type="button" hx-get="{% url 'mark_playlist_as' playlist.playlist_id 'favorite' %}" hx-target="#playlist-fav">
  265. <div id="playlist-fav">
  266. {% if playlist.is_favorite %}
  267. <i class="fas fa-star" style="color: #fafa06"></i>
  268. {% else %}
  269. <i class="far fa-star"></i>
  270. {% endif %}
  271. </div>
  272. </button>
  273. </div>
  274. <div class="btn-group me-2 mb-2">
  275. <a href="{% url 'view_playlist_settings' playlist.playlist_id %}" class="btn btn-primary">
  276. <i class="fas fa-cog"></i>
  277. </a>
  278. </div>
  279. {% if playlist_items.count != 0 %}
  280. <div class="btn-group me-2 mb-2">
  281. <button type="button" class="btn btn-light" onclick="row1_hide()">Manage</button>
  282. </div>
  283. {% endif %}
  284. </div>
  285. </div>
  286. </div>
  287. </div>
  288. <div id="row2" style="display: none">
  289. <div class="d-flex bd-highlight mb-1">
  290. <div class="me-auto bd-highlight">
  291. <div class="btn-toolbar mb-2 mb-md-0">
  292. <div id="select-all-btn">
  293. <div class="btn-group me-2 mb-2">
  294. <button type="button" class="btn btn-info" id="select-all-btn">Select All</button>
  295. </div>
  296. </div>
  297. <div id="deselect-all-btn" style="display: none">
  298. <div class="btn-group me-2 mb-2">
  299. <button type="button" class="btn btn-info" id="select-all-btn">De-select All</button>
  300. </div>
  301. </div>
  302. <div class="btn-group me-2 mb-2">
  303. <!-- <button type="submit" form="my-form" class="btn btn-outline-success" data-bs-toggle="dropdown" aria-expanded="false">
  304. Move
  305. </button> -->
  306. <button class="btn btn-success" id="move-copy-vids-btn" type="button" data-bs-toggle="collapse" data-bs-target="#moveItemsToCollapse" aria-expanded="false" aria-controls="moveItemsToCollapse">
  307. {% if playlist.is_user_owned %}Move/{% endif %}Copy Videos
  308. </button>
  309. </div>
  310. <!--
  311. <div class="btn-group me-2">
  312. <button type="button" class="btn btn-outline-warning" data-bs-toggle="dropdown" aria-expanded="false">
  313. Mark/Unmark Favorite
  314. </button>
  315. </div>
  316. -->
  317. {% if playlist.is_user_owned %}
  318. <div class="btn-group me-2 mb-2">
  319. <button class="btn btn-danger" data-bs-toggle="collapse" data-bs-target="#deleteItemsCollapse" aria-expanded="false" aria-controls="deleteItemsCollapse">
  320. Delete Videos
  321. </button>
  322. </div>
  323. {% endif %}
  324. </div>
  325. </div>
  326. <div class="bd-highlight">
  327. <div class="btn-toolbar mb-2 mb-md-0">
  328. <div class="btn-group me-2 mb-2">
  329. <button class="btn btn-primary" data-bs-toggle="collapse" data-bs-target="#addVideosCollapse" aria-expanded="false" aria-controls="addVideosCollapse">
  330. <i class="fa fa-plus"></i> Add New Videos
  331. </button>
  332. </div>
  333. <div class="btn-group me-2 mb-2">
  334. <button class="btn btn-dark" data-bs-toggle="collapse" data-bs-target="#createPlaylistCollapse" aria-expanded="false" aria-controls="createPlaylistCollapse">
  335. <i class="far fa-plus-square"></i> Create a New Playlist
  336. </button>
  337. </div>
  338. <div class="btn-group me-2 mb-2">
  339. <button type="button" class="btn btn-light" onclick="row1_show()" id="manageBtn">Manage</button>
  340. </div>
  341. </div>
  342. </div>
  343. </div>
  344. </div>
  345. <div id="row3" style="background-color: #0f5132">
  346. <div class="collapse border-danger" id="moveItemsToCollapse">
  347. <div class="card card-body bg-dark text-white">
  348. <h5>{% if playlist.is_user_owned %}Move or {% endif %}Copy videos to other playlist(s)! <span class="text-muted selected-videos-count">0 videos selected</span></h5>
  349. <div class="row d-flex justify-content-start">
  350. <div class="col-md-6 text-dark">
  351. <select class="visually-hidden"
  352. id="playlists-to-move-to" name="playlist-ids" placeholder="Select Playlists" multiple>
  353. {% for pl in user_owned_playlists %}
  354. {% if pl.playlist_id != playlist.playlist_id %}
  355. <option value="{{ pl.playlist_id }}" class="text-dark">{{ pl.name }}</option>
  356. {% endif %}
  357. {% endfor %}
  358. </select>
  359. </div>
  360. <div class="col-md d-flex justify-content-start">
  361. <div class="htmx-indicator d-flex align-items-center" id="move-copy-loader">
  362. <img src="{% static 'svg-loaders/grid.svg' %}" width="25" height="25" class="ms-2 mt-2">
  363. <span class="mt-2 ms-2">Loading, please wait... </span>
  364. </div>
  365. </div>
  366. </div>
  367. <div class="d-flex justify-content-start mt-2">
  368. {% if playlist.is_user_owned %}
  369. <div class="btn-group mt-1">
  370. <button hx-indicator="#move-copy-loader" hx-post="{% url 'playlist_move_copy_videos' playlist.playlist_id 'move' %}" hx-include="#playlists-to-move-to, #video-checkboxes" hx-target="#move-copy-videos-box" type="button" class="btn btn-primary">
  371. Move!
  372. </button>
  373. </div>
  374. {% endif %}
  375. <div class="btn-group ms-1 mt-1">
  376. <button hx-indicator="#move-copy-loader" hx-post="{% url 'playlist_move_copy_videos' playlist.playlist_id 'copy' %}" hx-include="#playlists-to-move-to, #video-checkboxes" hx-target="#move-copy-videos-box" type="button" class="btn btn-info">
  377. Copy!
  378. </button>
  379. </div>
  380. <div id="move-copy-videos-box" class="d-flex align-items-end ms-2">
  381. <span class="text-warning">Note: Move will delete the selected videos from this playlist. Copy won't.</span>
  382. </div>
  383. </div>
  384. </div>
  385. </div>
  386. </div>
  387. <div id="row4" style="background-color: #0f5132">
  388. <div class="collapse border-danger" id="deleteItemsCollapse">
  389. <div class="card card-body bg-dark text-white-50">
  390. <h5><span class="text-muted selected-videos-count">0 videos selected</span></h5>
  391. <div id="delete-videos-confirm-box">
  392. <h5>You can select videos by clicking any where on the video box. Selected videos will be highlighted red.</h5>
  393. {% if not user.profile.confirm_before_deleting %}
  394. <h5>
  395. <i class="fas fa-exclamation-triangle" style="color: yellow"></i>
  396. You have set confirm before deleting to False. Buttons below will take effect immediately when clicked.
  397. <i class="fas fa-exclamation-triangle" style="color: yellow"></i>
  398. </h5>
  399. <hr>
  400. {% else %}
  401. {% if playlist.has_unavailable_videos %}
  402. <h5><i class="fas fa-exclamation-triangle" style="color: yellow"></i> Clicking on delete unavailable videos button will take immediate effect. All videos labelled unavailable in this playlist will be deleted from your YouTube playlist.</h5>
  403. {% endif %}
  404. {% if playlist.has_duplicate_videos %}
  405. <h5><i class="fas fa-exclamation-triangle" style="color: yellow"></i> Clicking on delete duplicate videos button will take immediate effect. All videos labelled duplicate in this playlist will be deleted from your YouTube playlist.</h5>
  406. {% endif %}
  407. <hr>
  408. {% endif %}
  409. </div>
  410. <div class="d-flex justify-content-start">
  411. <div class="btn-group me-2">
  412. <button hx-post="{% url 'delete_videos' playlist.playlist_id 'confirm' %}" hx-include="[id='video-checkboxes']" hx-vals='{"confirm before deleting": "{{ user.profile.confirm_before_deleting }}"}' hx-target="#delete-videos-confirm-box" type="button" class="btn btn-primary">
  413. Delete Selected
  414. </button>
  415. </div>
  416. {% if playlist.has_unavailable_videos %}
  417. <div class="btn-group me-2">
  418. <button hx-post="{% url 'delete_specific_videos' playlist.playlist_id 'unavailable' %}" hx-target="#delete-videos-confirm-box" type="button" class="btn btn-info" hx-indicator="#delete-loader">
  419. Delete {{ playlist.get_unavailable_videos_count }} Unavailable Videos
  420. </button>
  421. </div>
  422. {% endif %}
  423. {% if playlist.has_duplicate_videos %}
  424. <div class="btn-group me-2">
  425. <button hx-post="{% url 'delete_specific_videos' playlist.playlist_id 'duplicate' %}" hx-target="#delete-videos-confirm-box" type="button" class="btn btn-warning" hx-indicator="#delete-loader">
  426. Delete {{ playlist.get_duplicate_videos_count }} Duplicate Videos
  427. </button>
  428. </div>
  429. {% endif %}
  430. <div class="btn-group me-2">
  431. <button hx-post="{% url 'delete_videos' playlist.playlist_id 'confirm' %}" hx-vals='{"all": "yes", "confirm before deleting": "{{ user.profile.confirm_before_deleting }}"}' hx-target="#delete-videos-confirm-box" type="button" class="btn btn-danger">
  432. Empty this Playlist
  433. </button>
  434. </div>
  435. <div class="htmx-indicator d-flex align-items-center" id="delete-loader">
  436. <img src="{% static 'svg-loaders/grid.svg' %}" width="25" height="25" class="ms-2 mt-2">
  437. <span class="mt-2 ms-2">Deleting, please wait... </span>
  438. </div>
  439. </div>
  440. </div>
  441. </div>
  442. </div>
  443. <div id="row5" style="background-color: #0f5132">
  444. <div class="collapse border-danger" id="addVideosCollapse">
  445. <div class="card card-body bg-dark text-white">
  446. <h5>Add new videos to this playlist</h5>
  447. <div class="row d-flex justify-content-start">
  448. <div class="col-md-8 text-dark">
  449. <textarea name="add-videos-textarea" class="form-control" id="add-videos-textarea" placeholder="Enter video links or video IDs line by line here"
  450. rows="5">{{ manage_playlists_import_textarea }}</textarea>
  451. <div class="form-text">
  452. Note: You can only add 25 videos at a time. Find videos by
  453. <a href="{% url 'search' %}?mode=videos&type=all" target="_blank" style="color: #398439; text-decoration: none">searching on UnTube <i class="fas fa-external-link-alt"></i> </a> or
  454. <a href="https://www.youtube.com/" target="_blank" style="color: #ec2d90; text-decoration: none">searching on YouTube <i class="fas fa-external-link-alt"></i> </a>
  455. </div>
  456. </div>
  457. </div>
  458. <div class="d-flex justify-content-start mt-2">
  459. <div class="btn-group ms-1 mt-1">
  460. <button hx-indicator="#add-videos-loader" hx-post="{% url 'playlist_add_new_videos' playlist.playlist_id %}" hx-include="#add-videos-textarea" hx-target="#add-videos-box" type="button" class="btn btn-primary">
  461. Add
  462. </button>
  463. </div>
  464. <div id="add-videos-box" class="d-flex align-items-end ms-2 text-warning">
  465. </div>
  466. <div class="htmx-indicator d-flex align-items-center" id="add-videos-loader">
  467. <img src="{% static 'svg-loaders/grid.svg' %}" width="25" height="25" class="ms-2 mt-2">
  468. <span class="mt-2 ms-2 text-warning">Adding videos, please wait... </span>
  469. </div>
  470. </div>
  471. </div>
  472. </div>
  473. </div>
  474. <div id="row6" style="background-color: #0f5132">
  475. <div class="collapse border-danger" id="createPlaylistCollapse">
  476. <div class="card card-body bg-dark text-white">
  477. <h5>Create a new playlist with the selected videos <span class="text-muted selected-videos-count">0 videos selected</span></h5>
  478. <div class="row d-flex justify-content-start">
  479. <div class="col-md-8 text-dark">
  480. <div id="create-playlist-from">
  481. <input type="text" name="playlist-name" class="form-control" placeholder="Enter new playlist name">
  482. <textarea name="playlist-description" class="form-control mt-2" placeholder="Enter playlist description here"
  483. rows="5">{{ manage_playlists_import_textarea }}</textarea>
  484. </div>
  485. </div>
  486. </div>
  487. <div class="d-flex justify-content-start mt-2">
  488. <div class="btn-group ms-1 mt-1">
  489. <button hx-indicator="#create-playlist-loader" hx-post="{% url 'playlist_create_new_playlist' playlist.playlist_id %}" hx-include="#create-playlist-from, #video-checkboxes" hx-target="#create-playlist-box" type="button" class="btn btn-primary">
  490. Create
  491. </button>
  492. </div>
  493. <div id="create-playlist-box" class="d-flex align-items-end ms-2 text-warning">
  494. </div>
  495. <div class="htmx-indicator d-flex align-items-center" id="create-playlist-loader">
  496. <img src="{% static 'svg-loaders/grid.svg' %}" width="25" height="25" class="ms-2 mt-2">
  497. <span class="mt-2 ms-2 text-warning">Creating playlist, please wait... </span>
  498. </div>
  499. </div>
  500. </div>
  501. </div>
  502. </div>
  503. <div class="table-responsive" id="videos-div">
  504. <br>
  505. {% if playlist_items %}
  506. <div class="list-group" id="video-checkboxes">
  507. {% for playlist_item in playlist_items|slice:"0:50" %}
  508. <li id="{{ playlist_item.playlist_item_id }}" onclick="selectVideo(this);" {% if forloop.last and playlist_items.count > 50 %}hx-get="{% url 'load_more_videos' playlist.playlist_id order_by|default:"all" page|default:"1" %}"
  509. hx-trigger="revealed"
  510. hx-swap="afterend" hx-indicator="#load-more-videos-spinner" {% endif %} class="list-group-item d-flex justify-content-between align-items-center bg-transparent videos" style="background-color: #40B3A2">
  511. {% if playlist_item.video.is_unavailable_on_yt and not playlist_item.video.was_deleted_on_yt %}
  512. <div class="d-flex justify-content-between align-items-center">
  513. <div>
  514. <input class="video-checkboxes" style="display: none" type="checkbox" value="{{ playlist_item.playlist_item_id }}" id="video-{{ playlist_item.playlist_item_id }}" name="video-id">
  515. </div>
  516. <div class="ms-4" style="max-width: 115px; max-height: 100px;">
  517. <img src="https://i.ytimg.com/vi/9219YrnwDXE/maxresdefault.jpg" class="img-fluid" alt="">
  518. </div>
  519. <div class="ms-4">
  520. <a class="link-dark" href="{% url 'video' playlist_item.video.video_id %}">
  521. {{ playlist_item.video_position|add:"1" }}. {{ playlist_item.video.name }}
  522. </a>
  523. <br><br>
  524. </div>
  525. </div>
  526. {% else %}
  527. <div class="d-flex justify-content-between align-items-center" >
  528. <div>
  529. <input class="video-checkboxes" style="display: none" type="checkbox" value="{{ playlist_item.playlist_item_id }}" id="video-{{ playlist_item.playlist_item_id }}" name="video-id">
  530. </div>
  531. <div class="ms-4" style="max-width: 115px; max-height: 100px;">
  532. <img src="{% if playlist_item.video.thumbnail_url %}{{ playlist_item.video.thumbnail_url }}{% else %}https://i.ytimg.com/vi/9219YrnwDXE/maxresdefault.jpg{% endif %}" class="img-fluid" alt="">
  533. </div>
  534. <div class="ms-4">
  535. {% if playlist_item.video.is_unavailable_on_yt or playlist_item.video.was_deleted_on_yt %}
  536. {{ playlist_item.video_position|add:"1" }}.
  537. <a class="link-dark" href="{% url 'video' playlist_item.video.video_id %}">
  538. {{ playlist_item.video.name|truncatewords:"16" }}
  539. </a>
  540. <br>
  541. <span class="badge bg-dark">VIDEO UNAVAILABLE</span>
  542. {% if playlist_item.video.video_details_modified %}<span class="badge bg-danger">WENT PRIVATE/DELETED {{ playlist_item.video.updated_at|naturaltime|upper }}</span>{% endif %}
  543. <br><br>
  544. {% else %}
  545. {{ playlist_item.video_position|add:"1" }}.
  546. <a class="link-dark" href="{% url 'video' playlist_item.video.video_id %}">
  547. {{ playlist_item.video.name|truncatewords:"16" }}
  548. </a> by <a href="{% url 'search' %}?mode=videos&channel={{ playlist_item.video.channel_name }}" style="text-decoration: none; color: black"><span style="border-bottom: 3px #e35959 dashed;"> {{ playlist_item.video.channel_name }}</span></a><br>
  549. <a style="text-decoration: none" hx-get="{% url 'video_completion_times' playlist_item.video.video_id %}" hx-trigger="click once" hx-target="#{{ playlist_item.playlist_item_id }}-completion-times" data-bs-toggle="collapse" href="#{{ playlist_item.playlist_item_id }}DurationCollapse" role="button" aria-expanded="false" aria-controls="{{ playlist_item.playlist_item_id }}DurationCollapse">
  550. <span class="badge bg-secondary">{{ playlist_item.video.duration }}</span>
  551. </a>
  552. <div class="collapse" id="{{ playlist_item.playlist_item_id }}DurationCollapse">
  553. <div class="card card-body bg-dark text-white text-capitalize border border-3 mt-2 mb-2 border-light">
  554. <div id="{{ playlist_item.playlist_item_id }}-completion-times">
  555. </div>
  556. </div>
  557. </div>
  558. {% if playlist_item.video.has_cc %}<span class="badge bg-danger">CC</span>{% endif %}
  559. {% if playlist_item.video.published_at %}<span class="badge bg-secondary">added to playlist on {{ playlist_item.published_at }}</span>{% endif %}
  560. <span class="badge bg-info text-black-50"><i class="fas fa-eye"></i> {% if playlist_item.video.view_count == -1 %}HIDDEN{% else %}{{ playlist_item.video.view_count|intword|intcomma }}{% endif %}</span>
  561. <span class="badge bg-warning text-black-50"><i class="fas fa-thumbs-up"></i> {% if playlist_item.video.like_count == -1 %}HIDDEN{% else %}{{ playlist_item.video.like_count|intword|intcomma }}{% endif %}</span>
  562. {% if playlist_item.is_duplicate %}<span class="badge bg-primary">duplicate</span>{% endif %}
  563. {% if playlist_item.video.playlists.count|add:"-1" != 0 %}
  564. <span class="badge bg-dark">
  565. <a href="{% url 'video' playlist_item.video.video_id %}#found-in" style="text-decoration: none; color: white">
  566. found in {{ playlist_item.video.playlists.count|add:"-1" }} other playlist{% if playlist_item.video.playlists.count|add:"-1" > 1 %}s{% endif %}
  567. </a></span>
  568. {% endif %}
  569. {% if playlist_item.video.video_details_modified %}<span class="badge bg-danger">{% if playlist_item.video.was_deleted_on_yt %}went private/deleted{% else %}added{% endif %} {{ playlist_item.created_at|naturaltime }}</span>{% endif %}<br>
  570. <br>
  571. {% endif %}
  572. </div>
  573. </div>
  574. <div class="ms-5">
  575. {% if playlist_item.video.is_unavailable_on_yt or playlist_item.video.was_deleted_on_yt %}
  576. <a class="btn btn-sm btn-primary mb-1" href="{% url 'video' playlist_item.video.video_id %}"><i class="fas fa-info"></i></a>
  577. <button class="btn btn-sm btn-dark mb-1" type="button" hx-get="{% url 'mark_video_favorite' playlist_item.video.video_id %}" hx-target="#video-{{ forloop.counter }}-fav">
  578. <div id="video-{{ forloop.counter }}-fav">
  579. {% if playlist_item.video.is_favorite %}
  580. <i class="fas fa-heart" style="color: #fafa06"></i>
  581. {% else %}
  582. <i class="far fa-heart"></i>
  583. {% endif %}
  584. </div>
  585. </button>
  586. {% else %}
  587. <a class="btn btn-sm btn-info mb-1" type="button" href="https://www.youtube.com/watch?v={{ playlist_item.video.video_id }}&list={{ playlist.playlist_id }}" class="btn btn-info me-1" target="_blank"><i class="fas fa-external-link-alt" aria-hidden="true"></i></a>
  588. <input class="form-control me-1 visually-hidden" id="video-{{ playlist_item.video.video_id }}" value="https://www.youtube.com/watch?v={{ playlist_item.video.video_id }}">
  589. <button class="copy-btn btn btn-sm btn-success mb-1" data-clipboard-target="#video-{{ playlist_item.video.video_id }}">
  590. <i class="far fa-copy" aria-hidden="true"></i>
  591. </button>
  592. <a class="btn btn-sm btn-primary mb-1" href="{% url 'video' playlist_item.video.video_id %}"><i class="fas fa-info"></i></a>
  593. <button class="btn btn-sm btn-dark mb-1" type="button" hx-get="{% url 'mark_video_favorite' playlist_item.video.video_id %}" hx-target="#video-{{ forloop.counter }}-fav">
  594. <div id="video-{{ forloop.counter }}-fav">
  595. {% if playlist_item.video.is_favorite %}
  596. <i class="fas fa-heart" style="color: #fafa06"></i>
  597. {% else %}
  598. <i class="far fa-heart"></i>
  599. {% endif %}
  600. </div>
  601. </button>
  602. {% if playlist.marked_as == "watching" and not playlist_item.is_duplicate %}
  603. <button class="btn btn-sm btn-light mb-1" type="button" hx-get="{% url 'mark_video_watched' playlist.playlist_id playlist_item.video.video_id %}" hx-target="#video-{{ forloop.counter }}-watched">
  604. <div id="video-{{ forloop.counter }}-watched">
  605. {% if playlist_item.video.is_marked_as_watched %}
  606. <i class="fas fa-check-circle"></i>
  607. {% else %}
  608. <i class="far fa-check-circle"></i>
  609. {% endif %}
  610. </div>
  611. </button>
  612. {% endif %}
  613. {% endif %}
  614. </div>
  615. {% endif %}
  616. </li>
  617. {% endfor %}
  618. </div>
  619. {% else %}
  620. <div class="card bg-dark text-white">
  621. <div class="card-body">
  622. <div class="d-flex justify-content-center align-content-center mt-2">
  623. Playlist is empty ;-;
  624. </div>
  625. <div class="d-flex justify-content-center align-content-center">
  626. Consider moving/copying videos from other playlists into this playlist.
  627. </div>
  628. <div class="d-flex justify-content-center align-content-center">
  629. - OR -
  630. </div>
  631. <div class="d-flex justify-content-center align-content-center">
  632. Add new videos to this playlist
  633. </div>
  634. <div class="d-flex justify-content-center mt-2">
  635. <textarea name="add-videos-textarea" class="form-control w-50" id="add-videos-textarea" placeholder="Enter video links or video IDs line by line here"
  636. rows="5">{{ manage_playlists_import_textarea }}</textarea>
  637. </div>
  638. <div class="d-flex justify-content-center">
  639. <div class="form-text">
  640. Note: You can only add 25 videos at a time. Find videos by
  641. <a href="{% url 'search' %}?mode=videos&type=all" target="_blank" style="color: #398439; text-decoration: none">searching on UnTube <i class="fas fa-external-link-alt"></i> </a> or
  642. <a href="https://www.youtube.com/" target="_blank" style="color: #ec2d90; text-decoration: none">searching on YouTube <i class="fas fa-external-link-alt"></i> </a>
  643. </div>
  644. </div>
  645. <div class="d-flex justify-content-center mt-2">
  646. <div class="btn-group ms-1 mt-1">
  647. <button hx-indicator="#add-videos-loader" hx-post="{% url 'playlist_add_new_videos' playlist.playlist_id %}" hx-include="#add-videos-textarea" hx-target="#add-videos-box" type="button" class="btn btn-primary">
  648. Add
  649. </button>
  650. </div>
  651. </div>
  652. <div class="d-flex justify-content-center mt-2">
  653. <div id="add-videos-box" class="d-flex align-items-end ms-2 text-warning">
  654. </div>
  655. <div class="htmx-indicator d-flex align-items-center" id="add-videos-loader">
  656. <img src="{% static 'svg-loaders/grid.svg' %}" width="25" height="25" class="ms-2 mt-2">
  657. <span class="mt-2 ms-2 text-warning">Adding videos, please wait... </span>
  658. </div>
  659. </div>
  660. </div>
  661. </div>
  662. {% endif %}
  663. </div>
  664. <div id="load-more-videos-spinner" class="d-flex htmx-indicator justify-content-center align-items-center">
  665. <div class="spinner-border mt-3" role="status">
  666. </div>
  667. <span class="mt-3 ms-2">Loading more videos...</span>
  668. </div>
  669. {% endif %}
  670. {% endif %}
  671. </div>
  672. <button class="scrollToTopBtn sticky-top">
  673. <i class="fa fa-angle-double-up fa-lg"></i></button>
  674. <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script>
  675. <script type="application/javascript">
  676. $(document).ready(function(){
  677. // multiple choices select search box
  678. var multipleCancelButton = new Choices('#playlists-to-move-to', {
  679. removeItemButton: true,
  680. });
  681. });
  682. $(function () {
  683. var $populationChart = $("#channel-videos-chart");
  684. $.ajax({
  685. url: $populationChart.data("url"),
  686. success: function (data) {
  687. var ctx = $populationChart[0].getContext("2d");
  688. var coloR = [];
  689. var dynamicColors = function() { // generate random color
  690. var r = Math.floor(Math.random() * 255);
  691. var g = Math.floor(Math.random() * 255);
  692. var b = Math.floor(Math.random() * 255);
  693. return "rgb(" + r + "," + g + "," + b + ")";
  694. };
  695. for (var i in data.labels) {
  696. if (data.labels)
  697. coloR.push(dynamicColors());
  698. }
  699. new Chart(ctx, {
  700. type: 'pie',
  701. data: {
  702. labels: data.labels,
  703. datasets: [{
  704. label: 'Videos',
  705. backgroundColor: coloR,
  706. data: data.data
  707. }]
  708. },
  709. options: {
  710. responsive: true,
  711. legend: {
  712. position: 'right',
  713. display: false
  714. },
  715. title: {
  716. display: true,
  717. text: 'Video Count Distribution per Channel',
  718. fontSize: 20,
  719. fontColor: '#fff',
  720. },
  721. }
  722. });
  723. }
  724. });
  725. });
  726. // when a video list item is clicked on, it gets checked and its bg turns red
  727. function selectVideo(video) {
  728. if ($('#row2').is(':visible')) {
  729. var videoCB = document.getElementById("video-" + video.id);
  730. if (videoCB.checked) {
  731. video.classList.remove("bg-danger");
  732. video.classList.add("bg-transparent");
  733. videoCB.checked = false;
  734. } else {
  735. video.classList.remove("bg-transparent");
  736. video.classList.add("bg-danger");
  737. videoCB.checked = true;
  738. }
  739. }
  740. displaySelectedVideosCount();
  741. }
  742. var moveCopyCollapse = document.getElementById('moveItemsToCollapse');
  743. var bsMoveCopyCollapse = new bootstrap.Collapse(moveCopyCollapse, {
  744. toggle: false
  745. });
  746. var deleteCollapse = document.getElementById('deleteItemsCollapse');
  747. var bsDeleteCollapse = new bootstrap.Collapse(deleteCollapse, {
  748. toggle: false
  749. });
  750. var addVideosCollapse = document.getElementById('addVideosCollapse');
  751. var bsAddVideosCollapse = new bootstrap.Collapse(addVideosCollapse, {
  752. toggle: false
  753. });
  754. var createPlaylistCollapse = document.getElementById('createPlaylistCollapse');
  755. var bsCreatePlaylistCollapse = new bootstrap.Collapse(createPlaylistCollapse, {
  756. toggle: false
  757. });
  758. function displaySelectedVideosCount() {
  759. var count = 0;
  760. var checkboxes = document.getElementsByClassName('video-checkboxes');
  761. for (var checkbox of checkboxes) {
  762. if (checkbox.checked) {
  763. count ++;
  764. }
  765. }
  766. var displayBoxes = document.getElementsByClassName('selected-videos-count');
  767. for (var displayBox of displayBoxes) {
  768. displayBox.innerHTML = count + " videos selected"
  769. }
  770. }
  771. document.getElementById('manageBtn').addEventListener('click', function () { document.getElementById("delete-videos-confirm-box").innerHTML = "";
  772. document.getElementById("delete-videos-confirm-box").innerHTML = `
  773. <h5>You can select videos by clicking any where on the video box. Selected videos will be highlighted red.</h5>
  774. {% if not user.profile.confirm_before_deleting %}
  775. <h5>
  776. <i class="fas fa-exclamation-triangle" style="color: yellow"></i>
  777. Note: You have set confirm before deleting to False. Buttons below will take effect immediately when clicked.
  778. <i class="fas fa-exclamation-triangle" style="color: yellow"></i>
  779. </h5>
  780. <hr>
  781. {% else %}
  782. {% if playlist.has_unavailable_videos %}
  783. <h5><i class="fas fa-exclamation-triangle" style="color: yellow"></i> Clicking on delete unavailable videos button will take immediate effect. All videos labelled unavailable in this playlist will be deleted from your YouTube playlist.</h5>
  784. {% endif %}
  785. {% if playlist.has_duplicate_videos %}
  786. <h5>Note: Clicking on delete duplicate videos button will take immediate effect. All videos labelled duplicate in this playlist will be deleted from your YouTube playlist.</h5>
  787. {% endif %}
  788. <hr>
  789. {% endif %}
  790. `;
  791. bsMoveCopyCollapse.hide();
  792. bsDeleteCollapse.hide();
  793. bsAddVideosCollapse.hide();
  794. bsCreatePlaylistCollapse.hide();
  795. var displayBoxes = document.getElementsByClassName('selected-videos-count');
  796. for (var displayBox of displayBoxes) {
  797. displayBox.innerHTML = "0 videos selected"
  798. }
  799. });
  800. moveCopyCollapse.addEventListener('show.bs.collapse', function () {
  801. bsDeleteCollapse.hide();
  802. bsAddVideosCollapse.hide();
  803. bsCreatePlaylistCollapse.hide();
  804. });
  805. deleteCollapse.addEventListener('show.bs.collapse', function () {
  806. bsMoveCopyCollapse.hide();
  807. bsAddVideosCollapse.hide();
  808. bsCreatePlaylistCollapse.hide();
  809. });
  810. addVideosCollapse.addEventListener('show.bs.collapse', function () {
  811. bsMoveCopyCollapse.hide();
  812. bsDeleteCollapse.hide();
  813. bsCreatePlaylistCollapse.hide();
  814. });
  815. createPlaylistCollapse.addEventListener('show.bs.collapse', function () {
  816. bsMoveCopyCollapse.hide();
  817. bsDeleteCollapse.hide();
  818. bsAddVideosCollapse.hide();
  819. });
  820. <!-- end -->
  821. document.getElementById('select-all-btn').onclick = function() {
  822. document.getElementById('select-all-btn').style.display = "none";
  823. document.getElementById('deselect-all-btn').style.display = "block";
  824. var checkboxes = document.getElementsByClassName('video-checkboxes');
  825. for (var checkbox of checkboxes) {
  826. checkbox.checked = true;
  827. }
  828. var listItems = document.getElementsByClassName('videos'); //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.
  829. for(var i=0, len=listItems.length; i<len; i++)
  830. {
  831. if(listItems[i].classList.contains("bg-transparent")){
  832. listItems[i].classList.remove("bg-transparent");
  833. listItems[i].classList.add("bg-danger");
  834. }
  835. }
  836. displaySelectedVideosCount();
  837. }
  838. document.getElementById('deselect-all-btn').onclick = function() {
  839. document.getElementById('deselect-all-btn').style.display = "none";
  840. document.getElementById('select-all-btn').style.display = "block";
  841. var checkboxes = document.getElementsByClassName('video-checkboxes');
  842. for (var checkbox of checkboxes) {
  843. checkbox.checked = false;
  844. }
  845. var listItems = document.getElementsByClassName('videos'); //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.
  846. for(var i=0, len=listItems.length; i<len; i++)
  847. {
  848. if(listItems[i].classList.contains("bg-danger")){
  849. listItems[i].classList.remove("bg-danger");
  850. listItems[i].classList.add("bg-transparent");
  851. }
  852. }
  853. displaySelectedVideosCount();
  854. }
  855. function row1_hide() {
  856. document.getElementById("row1").style.display = "none";
  857. 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.
  858. for(var i=0, len=checkboxes.length; i<len; i++)
  859. {
  860. //checkboxes[i].style.display = "block";
  861. checkboxes[i].checked = false;
  862. }
  863. document.getElementById("row2").style.display = "block";
  864. }
  865. function row1_show() {
  866. document.getElementById("row1").style.display = "block";
  867. 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.
  868. for(var i=0, len=checkboxes.length; i<len; i++)
  869. {
  870. checkboxes[i].style.display = "none";
  871. checkboxes[i].checked = false;
  872. }
  873. document.getElementById("row2").style.display = "none";
  874. var listItems = document.getElementsByClassName('videos'); //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.
  875. for(var i=0, len=listItems.length; i<len; i++)
  876. {
  877. if(listItems[i].classList.contains("bg-danger")){
  878. listItems[i].classList.remove("bg-danger");
  879. listItems[i].classList.add("bg-transparent");
  880. }
  881. }
  882. }
  883. function select_all_checkboxes(source) {
  884. checkboxes = document.getElementsByClassName('big-checkbox');
  885. for(var i=0, n=checkboxes.length;i<n;i++) {
  886. checkboxes[i].checked = source.checked;
  887. }
  888. }
  889. </script>
  890. <!--
  891. <script src="{% static 'youtube-audio-player/iframe-api.js' %}"></script>
  892. <script src="{% static 'youtube-audio-player/yt.min.js' %}"></script>
  893. -->
  894. {% endblock %}