view_playlist.html 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  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>Note: You have set confirm before deleting to False. Buttons below will take effect immediately when clicked.</h5>
  395. <hr>
  396. {% else %}
  397. {% if playlist.has_unavailable_videos %}
  398. <h5>Note: 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>
  399. {% endif %}
  400. {% if playlist.has_duplicate_videos %}
  401. <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>
  402. {% endif %}
  403. <hr>
  404. {% endif %}
  405. </div>
  406. <div class="d-flex justify-content-start">
  407. <div class="btn-group me-2">
  408. <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">
  409. Delete Selected
  410. </button>
  411. </div>
  412. {% if playlist.has_unavailable_videos %}
  413. <div class="btn-group me-2">
  414. <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">
  415. Delete {{ playlist.get_unavailable_videos_count }} Unavailable Videos
  416. </button>
  417. </div>
  418. {% endif %}
  419. {% if playlist.has_duplicate_videos %}
  420. <div class="btn-group me-2">
  421. <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">
  422. Delete {{ playlist.get_duplicate_videos_count }} Duplicate Videos
  423. </button>
  424. </div>
  425. {% endif %}
  426. <div class="btn-group me-2">
  427. <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">
  428. Empty this Playlist
  429. </button>
  430. </div>
  431. <div class="htmx-indicator d-flex align-items-center" id="delete-loader">
  432. <img src="{% static 'svg-loaders/grid.svg' %}" width="25" height="25" class="ms-2 mt-2">
  433. <span class="mt-2 ms-2">Deleting, please wait... </span>
  434. </div>
  435. </div>
  436. </div>
  437. </div>
  438. </div>
  439. <div id="row5" style="background-color: #0f5132">
  440. <div class="collapse border-danger" id="addVideosCollapse">
  441. <div class="card card-body bg-dark text-white">
  442. <h5>Add new videos to this playlist</h5>
  443. <div class="row d-flex justify-content-start">
  444. <div class="col-md-8 text-dark">
  445. <textarea name="add-videos-textarea" class="form-control" id="add-videos-textarea" placeholder="Enter video links or video IDs line by line here"
  446. rows="5">{{ manage_playlists_import_textarea }}</textarea>
  447. <div class="form-text">
  448. Note: You can only add 25 videos at a time. Find videos by
  449. <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
  450. <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>
  451. </div>
  452. </div>
  453. </div>
  454. <div class="d-flex justify-content-start mt-2">
  455. <div class="btn-group ms-1 mt-1">
  456. <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">
  457. Add
  458. </button>
  459. </div>
  460. <div id="add-videos-box" class="d-flex align-items-end ms-2 text-warning">
  461. </div>
  462. <div class="htmx-indicator d-flex align-items-center" id="add-videos-loader">
  463. <img src="{% static 'svg-loaders/grid.svg' %}" width="25" height="25" class="ms-2 mt-2">
  464. <span class="mt-2 ms-2 text-warning">Adding videos, please wait... </span>
  465. </div>
  466. </div>
  467. </div>
  468. </div>
  469. </div>
  470. <div id="row6" style="background-color: #0f5132">
  471. <div class="collapse border-danger" id="createPlaylistCollapse">
  472. <div class="card card-body bg-dark text-white">
  473. <h5>Create a new playlist with the selected videos <span class="text-muted selected-videos-count">0 videos selected</span></h5>
  474. <div class="row d-flex justify-content-start">
  475. <div class="col-md-8 text-dark">
  476. <div id="create-playlist-from">
  477. <input type="text" name="playlist-name" class="form-control" placeholder="Enter new playlist name">
  478. <textarea name="create-playlist-textarea" class="form-control mt-2" id="create-playlist-text-area" placeholder="Enter playlist description here" rows="5"
  479. hx-post="{% url 'manage_save' 'manage_playlists_import_textarea' %}"
  480. hx-trigger="keyup changed delay:500ms"
  481. hx-indicator="#spinner">{{ manage_playlists_import_textarea }}</textarea>
  482. </div>
  483. </div>
  484. </div>
  485. <div class="d-flex justify-content-start mt-2">
  486. <div class="btn-group ms-1 mt-1">
  487. <button hx-indicator="#create-playlist-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-primary">
  488. Create
  489. </button>
  490. </div>
  491. <div id="add-videos-box" class="d-flex align-items-end ms-2">
  492. </div>
  493. <div class="htmx-indicator d-flex align-items-center" id="create-playlist-loader">
  494. <img src="{% static 'svg-loaders/grid.svg' %}" width="25" height="25" class="ms-2 mt-2">
  495. <span class="mt-2 ms-2 text-warning">Creating playlist, please wait... </span>
  496. </div>
  497. </div>
  498. </div>
  499. </div>
  500. </div>
  501. <div class="table-responsive" id="videos-div">
  502. <br>
  503. {% if playlist_items %}
  504. <div class="list-group" id="video-checkboxes">
  505. {% for playlist_item in playlist_items|slice:"0:50" %}
  506. <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" %}"
  507. hx-trigger="revealed"
  508. 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">
  509. {% if playlist_item.video.is_unavailable_on_yt and not playlist_item.video.was_deleted_on_yt %}
  510. <div class="d-flex justify-content-between align-items-center">
  511. <div>
  512. <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">
  513. </div>
  514. <div class="ms-4" style="max-width: 115px; max-height: 100px;">
  515. <img src="https://i.ytimg.com/vi/9219YrnwDXE/maxresdefault.jpg" class="img-fluid" alt="">
  516. </div>
  517. <div class="ms-4">
  518. <a class="link-dark" href="{% url 'video' playlist_item.video.video_id %}">
  519. {{ playlist_item.video_position|add:"1" }}. {{ playlist_item.video.name }}
  520. </a>
  521. <br><br>
  522. </div>
  523. </div>
  524. {% else %}
  525. <div class="d-flex justify-content-between align-items-center" >
  526. <div>
  527. <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">
  528. </div>
  529. <div class="ms-4" style="max-width: 115px; max-height: 100px;">
  530. <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="">
  531. </div>
  532. <div class="ms-4">
  533. {% if playlist_item.video.is_unavailable_on_yt or playlist_item.video.was_deleted_on_yt %}
  534. {{ playlist_item.video_position|add:"1" }}.
  535. <a class="link-dark" href="{% url 'video' playlist_item.video.video_id %}">
  536. {{ playlist_item.video.name|truncatewords:"16" }}
  537. </a>
  538. <br>
  539. <span class="badge bg-dark">VIDEO UNAVAILABLE</span>
  540. {% if playlist_item.video.video_details_modified %}<span class="badge bg-danger">WENT PRIVATE/DELETED {{ playlist_item.video.updated_at|naturaltime|upper }}</span>{% endif %}
  541. <br><br>
  542. {% else %}
  543. {{ playlist_item.video_position|add:"1" }}.
  544. <a class="link-dark" href="{% url 'video' playlist_item.video.video_id %}">
  545. {{ playlist_item.video.name|truncatewords:"16" }}
  546. </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>
  547. <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">
  548. <span class="badge bg-secondary">{{ playlist_item.video.duration }}</span>
  549. </a>
  550. <div class="collapse" id="{{ playlist_item.playlist_item_id }}DurationCollapse">
  551. <div class="card card-body bg-dark text-white text-capitalize border border-3 mt-2 mb-2 border-light">
  552. <div id="{{ playlist_item.playlist_item_id }}-completion-times">
  553. </div>
  554. </div>
  555. </div>
  556. {% if playlist_item.video.has_cc %}<span class="badge bg-danger">CC</span>{% endif %}
  557. {% if playlist_item.video.published_at %}<span class="badge bg-secondary">added to playlist on {{ playlist_item.published_at }}</span>{% endif %}
  558. <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>
  559. <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>
  560. {% if playlist_item.is_duplicate %}<span class="badge bg-primary">duplicate</span>{% endif %}
  561. {% if playlist_item.video.playlists.count|add:"-1" != 0 %}
  562. <span class="badge bg-dark">
  563. <a href="{% url 'video' playlist_item.video.video_id %}#found-in" style="text-decoration: none; color: white">
  564. found in {{ playlist_item.video.playlists.count|add:"-1" }} other playlist{% if playlist_item.video.playlists.count|add:"-1" > 1 %}s{% endif %}
  565. </a></span>
  566. {% endif %}
  567. {% 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>
  568. <br>
  569. {% endif %}
  570. </div>
  571. </div>
  572. <div class="ms-5">
  573. {% if playlist_item.video.is_unavailable_on_yt or playlist_item.video.was_deleted_on_yt %}
  574. <a class="btn btn-sm btn-primary mb-1" href="{% url 'video' playlist_item.video.video_id %}"><i class="fas fa-info"></i></a>
  575. <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">
  576. <div id="video-{{ forloop.counter }}-fav">
  577. {% if playlist_item.video.is_favorite %}
  578. <i class="fas fa-heart" style="color: #fafa06"></i>
  579. {% else %}
  580. <i class="far fa-heart"></i>
  581. {% endif %}
  582. </div>
  583. </button>
  584. {% else %}
  585. <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>
  586. <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 }}">
  587. <button class="copy-btn btn btn-sm btn-success mb-1" data-clipboard-target="#video-{{ playlist_item.video.video_id }}">
  588. <i class="far fa-copy" aria-hidden="true"></i>
  589. </button>
  590. <a class="btn btn-sm btn-primary mb-1" href="{% url 'video' playlist_item.video.video_id %}"><i class="fas fa-info"></i></a>
  591. <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">
  592. <div id="video-{{ forloop.counter }}-fav">
  593. {% if playlist_item.video.is_favorite %}
  594. <i class="fas fa-heart" style="color: #fafa06"></i>
  595. {% else %}
  596. <i class="far fa-heart"></i>
  597. {% endif %}
  598. </div>
  599. </button>
  600. {% if playlist.marked_as == "watching" and not playlist_item.is_duplicate %}
  601. <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">
  602. <div id="video-{{ forloop.counter }}-watched">
  603. {% if playlist_item.video.is_marked_as_watched %}
  604. <i class="fas fa-check-circle"></i>
  605. {% else %}
  606. <i class="far fa-check-circle"></i>
  607. {% endif %}
  608. </div>
  609. </button>
  610. {% endif %}
  611. {% endif %}
  612. </div>
  613. {% endif %}
  614. </li>
  615. {% endfor %}
  616. </div>
  617. {% else %}
  618. <div class="card bg-dark text-white">
  619. <div class="card-body">
  620. <div class="d-flex justify-content-center align-content-center mt-2">
  621. Playlist is empty ;-;
  622. </div>
  623. <div class="d-flex justify-content-center align-content-center">
  624. Consider moving/copying videos from other playlists into this playlist by copying and using this playlist's ID.
  625. </div>
  626. <div class="d-flex justify-content-center align-content-center">
  627. - OR -
  628. </div>
  629. <div class="d-flex justify-content-center align-content-center">
  630. Add new videos to this playlist
  631. </div>
  632. <div class="d-flex justify-content-center mt-2">
  633. <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"
  634. rows="5">{{ manage_playlists_import_textarea }}</textarea>
  635. </div>
  636. <div class="d-flex justify-content-center">
  637. <div class="form-text">
  638. Note: You can only add 25 videos at a time. Find videos by
  639. <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
  640. <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>
  641. </div>
  642. </div>
  643. <div class="d-flex justify-content-center mt-2">
  644. <div class="btn-group ms-1 mt-1">
  645. <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">
  646. Add
  647. </button>
  648. </div>
  649. </div>
  650. <div class="d-flex justify-content-center mt-2">
  651. <div id="add-videos-box" class="d-flex align-items-end ms-2 text-warning">
  652. </div>
  653. <div class="htmx-indicator d-flex align-items-center" id="add-videos-loader">
  654. <img src="{% static 'svg-loaders/grid.svg' %}" width="25" height="25" class="ms-2 mt-2">
  655. <span class="mt-2 ms-2 text-warning">Adding videos, please wait... </span>
  656. </div>
  657. </div>
  658. </div>
  659. </div>
  660. {% endif %}
  661. </div>
  662. <div id="load-more-videos-spinner" class="d-flex htmx-indicator justify-content-center align-items-center">
  663. <div class="spinner-border mt-3" role="status">
  664. </div>
  665. <span class="mt-3 ms-2">Loading more videos...</span>
  666. </div>
  667. {% endif %}
  668. {% endif %}
  669. </div>
  670. <button class="scrollToTopBtn sticky-top">
  671. <i class="fa fa-angle-double-up fa-lg"></i></button>
  672. <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script>
  673. <script type="application/javascript">
  674. $(document).ready(function(){
  675. // multiple choices select search box
  676. var multipleCancelButton = new Choices('#playlists-to-move-to', {
  677. removeItemButton: true,
  678. });
  679. });
  680. $(function () {
  681. var $populationChart = $("#channel-videos-chart");
  682. $.ajax({
  683. url: $populationChart.data("url"),
  684. success: function (data) {
  685. var ctx = $populationChart[0].getContext("2d");
  686. var coloR = [];
  687. var dynamicColors = function() { // generate random color
  688. var r = Math.floor(Math.random() * 255);
  689. var g = Math.floor(Math.random() * 255);
  690. var b = Math.floor(Math.random() * 255);
  691. return "rgb(" + r + "," + g + "," + b + ")";
  692. };
  693. for (var i in data.labels) {
  694. if (data.labels)
  695. coloR.push(dynamicColors());
  696. }
  697. new Chart(ctx, {
  698. type: 'pie',
  699. data: {
  700. labels: data.labels,
  701. datasets: [{
  702. label: 'Videos',
  703. backgroundColor: coloR,
  704. data: data.data
  705. }]
  706. },
  707. options: {
  708. responsive: true,
  709. legend: {
  710. position: 'right',
  711. display: false
  712. },
  713. title: {
  714. display: true,
  715. text: 'Video Count Distribution per Channel',
  716. fontSize: 20,
  717. fontColor: '#fff',
  718. },
  719. }
  720. });
  721. }
  722. });
  723. });
  724. // when a video list item is clicked on, it gets checked and its bg turns red
  725. function selectVideo(video) {
  726. if ($('#row2').is(':visible')) {
  727. var videoCB = document.getElementById("video-" + video.id);
  728. if (videoCB.checked) {
  729. video.classList.remove("bg-danger");
  730. video.classList.add("bg-transparent");
  731. videoCB.checked = false;
  732. } else {
  733. video.classList.remove("bg-transparent");
  734. video.classList.add("bg-danger");
  735. videoCB.checked = true;
  736. }
  737. }
  738. displaySelectedVideosCount();
  739. }
  740. var moveCopyCollapse = document.getElementById('moveItemsToCollapse');
  741. var bsMoveCopyCollapse = new bootstrap.Collapse(moveCopyCollapse, {
  742. toggle: false
  743. });
  744. var deleteCollapse = document.getElementById('deleteItemsCollapse');
  745. var bsDeleteCollapse = new bootstrap.Collapse(deleteCollapse, {
  746. toggle: false
  747. });
  748. var addVideosCollapse = document.getElementById('addVideosCollapse');
  749. var bsAddVideosCollapse = new bootstrap.Collapse(addVideosCollapse, {
  750. toggle: false
  751. });
  752. var createPlaylistCollapse = document.getElementById('createPlaylistCollapse');
  753. var bsCreatePlaylistCollapse = new bootstrap.Collapse(createPlaylistCollapse, {
  754. toggle: false
  755. });
  756. function displaySelectedVideosCount() {
  757. var count = 0;
  758. var checkboxes = document.getElementsByClassName('video-checkboxes');
  759. for (var checkbox of checkboxes) {
  760. if (checkbox.checked) {
  761. count ++;
  762. }
  763. }
  764. var displayBoxes = document.getElementsByClassName('selected-videos-count');
  765. for (var displayBox of displayBoxes) {
  766. displayBox.innerHTML = count + " videos selected"
  767. }
  768. }
  769. document.getElementById('manageBtn').addEventListener('click', function () { document.getElementById("delete-videos-confirm-box").innerHTML = "";
  770. document.getElementById("delete-videos-confirm-box").innerHTML = `
  771. <h5>You can select videos by clicking any where on the video box. Selected videos will be highlighted red.</h5>
  772. {% if not user.profile.confirm_before_deleting %}
  773. <h5>Note: You have set confirm before deleting to False. Buttons below will take effect immediately when clicked.</h5>
  774. <hr>
  775. {% else %}
  776. {% if playlist.has_unavailable_videos %}
  777. <h5>Note: 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>
  778. {% endif %}
  779. {% if playlist.has_duplicate_videos %}
  780. <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>
  781. {% endif %}
  782. <hr>
  783. {% endif %}
  784. `;
  785. bsMoveCopyCollapse.hide();
  786. bsDeleteCollapse.hide();
  787. bsAddVideosCollapse.hide();
  788. bsCreatePlaylistCollapse.hide();
  789. var displayBoxes = document.getElementsByClassName('selected-videos-count');
  790. for (var displayBox of displayBoxes) {
  791. displayBox.innerHTML = "0 videos selected"
  792. }
  793. });
  794. moveCopyCollapse.addEventListener('show.bs.collapse', function () {
  795. bsDeleteCollapse.hide();
  796. bsAddVideosCollapse.hide();
  797. bsCreatePlaylistCollapse.hide();
  798. });
  799. deleteCollapse.addEventListener('show.bs.collapse', function () {
  800. bsMoveCopyCollapse.hide();
  801. bsAddVideosCollapse.hide();
  802. bsCreatePlaylistCollapse.hide();
  803. });
  804. addVideosCollapse.addEventListener('show.bs.collapse', function () {
  805. bsMoveCopyCollapse.hide();
  806. bsDeleteCollapse.hide();
  807. bsCreatePlaylistCollapse.hide();
  808. });
  809. createPlaylistCollapse.addEventListener('show.bs.collapse', function () {
  810. bsMoveCopyCollapse.hide();
  811. bsDeleteCollapse.hide();
  812. bsAddVideosCollapse.hide();
  813. });
  814. <!-- end -->
  815. document.getElementById('select-all-btn').onclick = function() {
  816. document.getElementById('select-all-btn').style.display = "none";
  817. document.getElementById('deselect-all-btn').style.display = "block";
  818. var checkboxes = document.getElementsByClassName('video-checkboxes');
  819. for (var checkbox of checkboxes) {
  820. checkbox.checked = true;
  821. }
  822. 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.
  823. for(var i=0, len=listItems.length; i<len; i++)
  824. {
  825. if(listItems[i].classList.contains("bg-transparent")){
  826. listItems[i].classList.remove("bg-transparent");
  827. listItems[i].classList.add("bg-danger");
  828. }
  829. }
  830. displaySelectedVideosCount();
  831. }
  832. document.getElementById('deselect-all-btn').onclick = function() {
  833. document.getElementById('deselect-all-btn').style.display = "none";
  834. document.getElementById('select-all-btn').style.display = "block";
  835. var checkboxes = document.getElementsByClassName('video-checkboxes');
  836. for (var checkbox of checkboxes) {
  837. checkbox.checked = false;
  838. }
  839. 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.
  840. for(var i=0, len=listItems.length; i<len; i++)
  841. {
  842. if(listItems[i].classList.contains("bg-danger")){
  843. listItems[i].classList.remove("bg-danger");
  844. listItems[i].classList.add("bg-transparent");
  845. }
  846. }
  847. displaySelectedVideosCount();
  848. }
  849. function row1_hide() {
  850. document.getElementById("row1").style.display = "none";
  851. 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.
  852. for(var i=0, len=checkboxes.length; i<len; i++)
  853. {
  854. //checkboxes[i].style.display = "block";
  855. checkboxes[i].checked = false;
  856. }
  857. document.getElementById("row2").style.display = "block";
  858. }
  859. function row1_show() {
  860. document.getElementById("row1").style.display = "block";
  861. 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.
  862. for(var i=0, len=checkboxes.length; i<len; i++)
  863. {
  864. checkboxes[i].style.display = "none";
  865. checkboxes[i].checked = false;
  866. }
  867. document.getElementById("row2").style.display = "none";
  868. 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.
  869. for(var i=0, len=listItems.length; i<len; i++)
  870. {
  871. if(listItems[i].classList.contains("bg-danger")){
  872. listItems[i].classList.remove("bg-danger");
  873. listItems[i].classList.add("bg-transparent");
  874. }
  875. }
  876. }
  877. function select_all_checkboxes(source) {
  878. checkboxes = document.getElementsByClassName('big-checkbox');
  879. for(var i=0, n=checkboxes.length;i<n;i++) {
  880. checkboxes[i].checked = source.checked;
  881. }
  882. }
  883. </script>
  884. <!--
  885. <script src="{% static 'youtube-audio-player/iframe-api.js' %}"></script>
  886. <script src="{% static 'youtube-audio-player/yt.min.js' %}"></script>
  887. -->
  888. {% endblock %}