Update html/poketube.ejs

This commit is contained in:
ashley 2024-07-16 12:40:42 +00:00
parent 40a8e92e80
commit c89ba51f57

View file

@ -719,6 +719,21 @@ background-color: #0000;
secs.toString().padStart(2, '0');
}
return timeString;
}
function cstsRemaining(totalTimeInSeconds, elapsedTimeInSeconds) {
var remainingSeconds = totalTimeInSeconds - elapsedTimeInSeconds;
var hours = Math.floor(remainingSeconds / 3600);
var minutes = Math.floor((remainingSeconds % 3600) / 60);
var secs = Math.floor(remainingSeconds % 60);
var timeString;
if (hours === 0) {
timeString = minutes.toString().padStart(2, '0') + ':' + secs.toString().padStart(2, '0');
} else {
timeString = hours.toString().padStart(2, '0') + ':' + minutes.toString().padStart(2, '0') + ':' + secs.toString().padStart(2, '0');
}
return '-' + timeString;
}
function showErrorCard(e) {
try {
@ -755,9 +770,18 @@ background-color: #0000;
let setTime = false
const seekbar = document.getElementById("duration-slider")
const video = document.getElementById("video");
let shouldUseRemaining = false;
const timestamps = document.getElementById("timestamps");
video.addEventListener("timeupdate", (event) => {
seekbar.value = event.target.currentTime;
const timestamps = document.getElementById("timestamps");
timestamps.innerText = shouldUseRemaining ? `${cstsRemaining(video.duration, video.currentTime)}/${csts(video.duration)}` : `${csts(video.currentTime)}/${csts(video.duration)}`;
});
timestamps.addEventListener("mouseover", () => {
shouldUseRemaining = true;
timestamps.innerText = `${cstsRemaining(video.duration, video.currentTime)}/${csts(video.duration)}`;
});
timestamps.addEventListener("mouseout", () => {
shouldUseRemaining = false;
timestamps.innerText = `${csts(video.currentTime)}/${csts(video.duration)}`;
});