view_playlist.html 64 KB

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