diff options
| author | Caian Benedicto <caianbene@gmail.com> | 2024-12-13 18:29:28 -0300 |
|---|---|---|
| committer | Caian Benedicto <caianbene@gmail.com> | 2024-12-13 20:26:52 -0300 |
| commit | d7f5cdc2f971af524c496aaeb25226eb9f8236df (patch) | |
| tree | 1e69d1088ee67407b1058f490cc188cd1dd4e287 /assets/js/watched_indicator.js | |
| parent | 78773d732672d8985795fb040a39dd7e946c7b7c (diff) | |
| parent | 98926047586154269bb269d01e3e52e60e044035 (diff) | |
| download | invidious-d7f5cdc2f971af524c496aaeb25226eb9f8236df.tar.gz invidious-d7f5cdc2f971af524c496aaeb25226eb9f8236df.tar.bz2 invidious-d7f5cdc2f971af524c496aaeb25226eb9f8236df.zip | |
Merge branch 'master' into unix-sockets
Diffstat (limited to 'assets/js/watched_indicator.js')
| -rw-r--r-- | assets/js/watched_indicator.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/assets/js/watched_indicator.js b/assets/js/watched_indicator.js new file mode 100644 index 00000000..e971cd80 --- /dev/null +++ b/assets/js/watched_indicator.js @@ -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 + '%'; +}); |
