mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-22 05:27:21 +00:00
Fixed console error
This commit is contained in:
parent
420e12bb8b
commit
bde21d527f
24
assets/js/watched_indicator.js
Normal file
24
assets/js/watched_indicator.js
Normal 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 + '%';
|
||||
});
|
@ -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 + '%';
|
||||
});
|
||||
|
@ -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) -%>
|
||||
|
@ -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>
|
||||
|
@ -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">
|
||||
|
@ -33,4 +33,4 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script src="/js/watched_widget.js"></script>
|
||||
<script src="/js/watched_indicator.js"></script>
|
||||
|
@ -17,4 +17,4 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script src="/js/watched_widget.js"></script>
|
||||
<script src="/js/watched_indicator.js"></script>
|
||||
|
@ -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">
|
||||
|
@ -46,4 +46,4 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script src="/js/watched_widget.js"></script>
|
||||
<script src="/js/watched_indicator.js"></script>
|
||||
|
@ -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">
|
||||
|
@ -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">
|
||||
|
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user