watched_indicator.js 662 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. var save_player_pos_key = 'save_player_pos';
  3. function get_all_video_times() {
  4. return helpers.storage.get(save_player_pos_key) || {};
  5. }
  6. document.querySelectorAll('.watched-indicator').forEach(function (indicator) {
  7. var watched_part = get_all_video_times()[indicator.dataset.id];
  8. var total = parseInt(indicator.dataset.length, 10);
  9. if (watched_part === undefined) {
  10. watched_part = total;
  11. }
  12. var percentage = Math.round((watched_part / total) * 100);
  13. if (percentage < 5) {
  14. percentage = 5;
  15. }
  16. if (percentage > 90) {
  17. percentage = 100;
  18. }
  19. indicator.style.width = percentage + '%';
  20. });