mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-13 08:42:59 -07:00
Make sure activity progress cannot exceed 100%
This commit is contained in:
parent
7f2e740bc0
commit
ff7fee6abf
2 changed files with 11 additions and 10 deletions
|
@ -305,21 +305,21 @@ DOCUMENTATION :: END
|
|||
ETA:
|
||||
<span id="stream-eta-${sk}">
|
||||
<script>
|
||||
$("#stream-eta-${sk}").html(moment().add(parseInt("${data['duration']}") - parseInt("${data['view_offset']}"), 'milliseconds').format(time_format));
|
||||
$("#stream-eta-${sk}").html(moment().add(parseInt("${data['stream_duration']}") - parseInt("${data['view_offset']}"), 'milliseconds').format(time_format));
|
||||
</script>
|
||||
</span><br /><span class="progress_time_offset" id="stream-view-offset-${sk}" data-last_view_offset="${data['view_offset']}" data-view_offset="${data['view_offset']}" data-state="${data['state']}">
|
||||
</span><br /><span class="progress_time_offset" id="stream-view-offset-${sk}" data-last_view_offset="${data['view_offset']}" data-view_offset="${data['view_offset']}" data-stream_duration="${data['stream_duration']}" data-state="${data['state']}">
|
||||
<script>
|
||||
$("#stream-view-offset-${sk}").html(millisecondsToMinutes(parseInt("${data['view_offset']}"), false));
|
||||
$("#stream-view-offset-${sk}").html(millisecondsToMinutes(parseInt("${data['view_offset']}"), false));
|
||||
</script>
|
||||
</span> / <span class="progress_time_total" id="stream-duration-${sk}">
|
||||
<script>
|
||||
$("#stream-duration-${sk}").html(millisecondsToMinutes(parseInt("${data['duration']}"), false));
|
||||
$("#stream-duration-${sk}").html(millisecondsToMinutes(parseInt("${data['stream_duration']}"), false));
|
||||
</script>
|
||||
</span>
|
||||
% else:
|
||||
ETA: Unknown<br />0:00 / <span class="progress_time_total" id="stream-duration-${sk}">
|
||||
<script>
|
||||
$("#stream-duration-${sk}").html(millisecondsToMinutes(parseInt("${data['duration']}"), false));
|
||||
$("#stream-duration-${sk}").html(millisecondsToMinutes(parseInt("${data['stream_duration']}"), false));
|
||||
</script>
|
||||
</span>
|
||||
% endif
|
||||
|
|
|
@ -522,18 +522,19 @@
|
|||
$('.progress_time_offset').each(function () {
|
||||
if ($(this).data('state') === 'playing' && $(this).data('view_offset')) {
|
||||
var view_offset = parseInt($(this).data('view_offset'));
|
||||
var timestamp = millisecondsToMinutes(view_offset, false);
|
||||
$(this).html(timestamp).data('view_offset', view_offset + 1000)
|
||||
var stream_duration = parseInt($(this).data('stream_duration'));
|
||||
var timestamp = millisecondsToMinutes(Math.min(view_offset, stream_duration), false);
|
||||
$(this).html(timestamp).data('view_offset', Math.min(view_offset + 1000, stream_duration))
|
||||
}
|
||||
});
|
||||
$('.progress-bar').each(function () {
|
||||
if ($(this).data('state') === 'playing' && $(this).data('view_offset')) {
|
||||
var view_offset = parseInt($(this).data('view_offset'));
|
||||
var duration = parseInt($(this).data('stream_duration'));
|
||||
var progress_percent = Math.trunc(view_offset / duration * 100)
|
||||
var stream_duration = parseInt($(this).data('stream_duration'));
|
||||
var progress_percent = Math.min(Math.trunc(view_offset / stream_duration * 100), 100)
|
||||
$(this).width(progress_percent - 3 + '%').html(progress_percent + '%')
|
||||
.attr('data-original-title', 'Stream Progress ' + progress_percent + '%')
|
||||
.data('view_offset', view_offset + 1000);
|
||||
.data('view_offset', Math.min(view_offset + 1000, stream_duration));
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue