Fixed console error

This commit is contained in:
Wes van der Vleuten 2023-02-19 20:41:18 +01:00
parent 420e12bb8b
commit bde21d527f
12 changed files with 35 additions and 34 deletions

View file

@ -0,0 +1,24 @@
'use strict';
var save_player_pos_key = 'save_player_pos';
function get_all_video_times() {
return helpers.storage.get(save_player_pos_key) || {};
}
document.querySelectorAll('.watched-indicator').forEach(function (indicator) {
var watched_part = get_all_video_times()[indicator.dataset.id];
var total = parseInt(indicator.dataset.length, 10);
if (watched_part === undefined) {
watched_part = total;
}
var percentage = Math.round((watched_part / total) * 100);
if (percentage < 5) {
percentage = 5;
}
if (percentage > 90) {
percentage = 100;
}
indicator.style.width = percentage + '%';
});

View file

@ -32,27 +32,3 @@ function mark_unwatched(target) {
}
});
}
var save_player_pos_key = 'save_player_pos';
function get_all_video_times() {
return helpers.storage.get(save_player_pos_key) || {};
}
document.querySelectorAll('.watched-indicator').forEach(function (indicator) {
var watched_part = get_all_video_times()[indicator.dataset.id];
var total = parseInt(indicator.dataset.length, 10);
if (watched_part === undefined) {
watched_part = total;
}
var percentage = Math.round((watched_part / total) * 100);
if (percentage < 5) {
percentage = 5;
}
if (percentage > 90) {
percentage = 100;
}
indicator.style.width = percentage + '%';
});

View file

@ -39,7 +39,7 @@
<% end %>
</div>
<script src="/js/watched_widget.js"></script>
<script src="/js/watched_indicator.js"></script>
<% if query %>
<%- query_encoded = URI.encode_www_form(query.text, space_to_plus: true) -%>

View file

@ -49,7 +49,7 @@
<% end %>
</div>
<script src="/js/watched_widget.js"></script>
<script src="/js/watched_indicator.js"></script>
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-md-4-5"></div>

View file

@ -62,7 +62,7 @@
<% end %>
</div>
<script src="/js/watched_widget.js"></script>
<script src="/js/watched_indicator.js"></script>
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-lg-1-5">

View file

@ -33,4 +33,4 @@
<% end %>
</div>
<script src="/js/watched_widget.js"></script>
<script src="/js/watched_indicator.js"></script>

View file

@ -17,4 +17,4 @@
<% end %>
</div>
<script src="/js/watched_widget.js"></script>
<script src="/js/watched_indicator.js"></script>

View file

@ -54,6 +54,7 @@
}.to_pretty_json
%>
</script>
<script src="/js/watched_widget.js"></script>
<div class="pure-g">
<% videos.each do |item| %>
@ -61,7 +62,7 @@
<% end %>
</div>
<script src="/js/watched_widget.js"></script>
<script src="/js/watched_indicator.js"></script>
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-lg-1-5">

View file

@ -46,4 +46,4 @@
<% end %>
</div>
<script src="/js/watched_widget.js"></script>
<script src="/js/watched_indicator.js"></script>

View file

@ -24,7 +24,7 @@
<%- end -%>
</div>
<script src="/js/watched_widget.js"></script>
<script src="/js/watched_indicator.js"></script>
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-lg-1-5">

View file

@ -106,7 +106,7 @@
<% end %>
</div>
<script src="/js/watched_widget.js"></script>
<script src="/js/watched_indicator.js"></script>
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-lg-1-5">

View file

@ -37,7 +37,7 @@
</div>
<%- end -%>
<script src="/js/watched_widget.js"></script>
<script src="/js/watched_indicator.js"></script>
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-lg-1-5">