32 lines
619 B
JavaScript
32 lines
619 B
JavaScript
document.addEventListener('click', (event) => {
|
|
const decision = event.target.closest('[data-course-decision]');
|
|
const restart = event.target.closest('[data-course-restart]');
|
|
const button = decision || restart;
|
|
|
|
if (!button) {
|
|
return;
|
|
}
|
|
|
|
const video = button.closest('li')?.querySelector('video');
|
|
|
|
if (!video) {
|
|
return;
|
|
}
|
|
|
|
if (restart) {
|
|
video.currentTime = 0;
|
|
video.play();
|
|
|
|
return;
|
|
}
|
|
|
|
const at = Number(video.dataset.decision);
|
|
|
|
if (Number.isNaN(at)) {
|
|
return;
|
|
}
|
|
|
|
video.currentTime = at;
|
|
video.pause();
|
|
});
|