Skip to content

Commit

Permalink
Use setUpMaxTime() from thymeUtility and remove unnecessary time upda…
Browse files Browse the repository at this point in the history
…te listener.
  • Loading branch information
Frodo161 committed Sep 17, 2023
1 parent 7dafa8c commit 7c90f4c
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions app/assets/javascripts/thyme_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ $(document).on('turbolinks:load', function() {
(new SeekBar('seek-bar')).add();
(new VolumeBar('volume-bar')).add();

thymeUtility.setUpMaxTime('max-time');



const addItemButton = document.getElementById('add-item');
const addReferenceButton = document.getElementById('add-reference');
const addScreenshotButton = document.getElementById('add-screenshot');
// Times
const currentTime = document.getElementById('current-time');
const maxTime = document.getElementById('max-time');
// Screenshot Canvas
const canvas = document.getElementById('snapshot');

Expand Down Expand Up @@ -115,18 +114,4 @@ $(document).on('turbolinks:load', function() {
});
});

/* after video metadata have been loaded, set up video length, volume bar and
seek bar */
video.addEventListener('loadedmetadata', function() {
maxTime.innerHTML = thymeUtility.secondsToTime(video.duration);
canvas.width = Math.floor($(video).width());
canvas.height = Math.floor($(video).height());
});

// Update the seek bar as the video plays
video.addEventListener('timeupdate', function() {
const value = 100 / video.duration * video.currentTime;
currentTime.innerHTML = thymeUtility.secondsToTime(video.currentTime);
});

});

0 comments on commit 7c90f4c

Please sign in to comment.