mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-09 15:02:14 +05:30
abbreviated length logic abstracted into a helper function
This commit is contained in:
parent
a6df381c16
commit
2bdd20906c
@ -11,6 +11,22 @@ def ci_lower_bound(pos, n)
|
||||
return (phat + z*z/(2*n) - z * Math.sqrt((phat*(1 - phat) + z*z/(4*n))/n))/(1 + z*z/n)
|
||||
end
|
||||
|
||||
def video_length_abbreviated(length)
|
||||
length_abbreviated = ""
|
||||
if length.days > 0
|
||||
length_abbreviated = "#{length.days} d #{length.hours} hr #{length.minutes} min"
|
||||
elsif length.hours > 0
|
||||
length_abbreviated = "#{length.hours} h #{length.minutes} min"
|
||||
elsif length.minutes > 0
|
||||
length_abbreviated = "#{length.minutes} min"
|
||||
else
|
||||
length_abbreviated = "#{length.seconds} seconds"
|
||||
end
|
||||
|
||||
return length_abbreviated
|
||||
|
||||
end
|
||||
|
||||
def elapsed_text(elapsed)
|
||||
millis = elapsed.total_milliseconds
|
||||
return "#{millis.round(2)}ms" if millis >= 1
|
||||
|
@ -77,17 +77,7 @@ we're going to need to do it here in order to allow for translations.
|
||||
<h1>
|
||||
<%= title %>
|
||||
<span class="length-watch-page">
|
||||
<% time_span_length = video.length_seconds.seconds %>
|
||||
|
||||
<% if time_span_length.days > 0 %>
|
||||
<%= time_span_length.days %> d <%= time_span_length.hours %> hr <%= time_span_length.minutes %> min
|
||||
<% elsif time_span_length.hours > 0 %>
|
||||
<%= time_span_length.hours %> hr <%= time_span_length.minutes %> min
|
||||
<% elsif time_span_length.minutes > 0 %>
|
||||
<%= time_span_length.minutes %> min
|
||||
<% else %>
|
||||
<%= time_span_length.seconds %> seconds
|
||||
<% end %>
|
||||
<%= video_length_abbreviated(video.length_seconds.seconds)%>
|
||||
</span>
|
||||
<% if params.listen %>
|
||||
<a title="<%=translate(locale, "Video mode")%>" href="/watch?<%= env.params.query %>&listen=0">
|
||||
|
Loading…
Reference in New Issue
Block a user