invidious/src/invidious/views/components/description_chapters_widget.ecr
syeopite 99d2df34a6
Add data-jump-time attribute to chapters component
Allows automatically jumping to specified time instead of reloading the
page.
2023-08-21 15:36:23 -07:00

29 lines
1.8 KiB
Plaintext

<% if !chapters.empty? %>
<div class="description-chapters-section">
<hr class="description-content-separator"/>
<h4>Chapters</h4>
<div class="description-chapters-content-container">
<% chapters.each do | chapter | %>
<%- start_in_seconds = chapter.start_ms.milliseconds.total_seconds.to_i %>
<a href="/watch?v=<%-= video.id %>&t=<%=start_in_seconds %>">
<div class="chapter" data-onclick="jump_to_time" data-jump-time="<%=start_in_seconds%>">
<div class="thumbnail">
<%- if !env.get("preferences").as(Preferences).thin_mode -%>
<img loading="lazy" class="thumbnail" src="<%-=URI.parse(chapter.thumbnails[-1]["url"].to_s).request_target %>" alt="" data-onclick="jump_to_time" data-jump-time="<%=start_in_seconds%>"/>
<%- else -%>
<div class="thumbnail-placeholder" data-onclick="jump_to_time" data-jump-time="<%=start_in_seconds%>"></div>
<%- end -%>
</div>
<%- if start_in_seconds > 0 -%>
<p data-onclick="jump_to_time" data-jump-time="<%=start_in_seconds%>"><%-= recode_length_seconds(start_in_seconds) -%></p>
<%- else -%>
<p data-onclick="jump_to_time" data-jump-time="<%=start_in_seconds%>">0:00</p>
<%- end -%>
<p data-onclick="jump_to_time" data-jump-time="<%=start_in_seconds%>"><%-=chapter.title-%></p>
</div>
</a>
<% end %>
</div>
<hr class="description-content-separator"/>
</div>
<% end %>