2024-09-07 18:12:58 -04:00
|
|
|
async function formClick(ev) {
|
|
|
|
ev.preventDefault();
|
|
|
|
|
|
|
|
let { target } = ev;
|
|
|
|
|
2024-09-20 15:34:16 -04:00
|
|
|
let fData = new FormData(target);
|
|
|
|
|
2024-09-21 10:23:29 -04:00
|
|
|
let file = target.querySelector('input[type=file]');
|
|
|
|
if (file)
|
|
|
|
file.value = null;
|
2024-09-20 15:34:16 -04:00
|
|
|
|
2024-09-07 18:12:58 -04:00
|
|
|
let fetched = await fetch(target.action, {
|
|
|
|
'method': 'POST',
|
2024-09-20 15:34:16 -04:00
|
|
|
'body': fData
|
2024-09-07 18:12:58 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
let json = await fetched.json();
|
|
|
|
|
2024-11-01 17:53:00 -04:00
|
|
|
target.querySelector('.captcha').src += '&a=b';
|
|
|
|
|
2024-09-22 19:11:15 -04:00
|
|
|
target.querySelector('.form-message').textContent = json.message;
|
2024-09-07 18:12:58 -04:00
|
|
|
|
|
|
|
if (json.redirect) {
|
|
|
|
setTimeout(function () {
|
|
|
|
window.location.href = json.redirect;
|
|
|
|
}, 2000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-19 18:38:24 -04:00
|
|
|
function moveBar(e, bar, vid) {
|
|
|
|
let rect = bar.getBoundingClientRect();
|
|
|
|
let prog = ((e.pageX - rect.x) / rect.width);
|
2024-09-20 08:38:33 -04:00
|
|
|
|
2024-09-19 18:38:24 -04:00
|
|
|
vid.currentTime = prog * vid.duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
function prog(vid, bar) {
|
|
|
|
bar.querySelector('div').style.width = `${vid.currentTime / vid.duration * 100}%`;
|
|
|
|
}
|
|
|
|
|
|
|
|
function controls(vid) {
|
2024-09-22 07:35:03 -04:00
|
|
|
let isFull = false;
|
2024-09-20 08:38:33 -04:00
|
|
|
let bar = vid.querySelector('.progressbar');
|
2024-09-19 18:38:24 -04:00
|
|
|
let video = vid.querySelector('video');
|
2024-09-20 08:38:33 -04:00
|
|
|
let play = vid.querySelector('.play');
|
2024-10-25 21:06:23 -04:00
|
|
|
let h = document.querySelector('.header');
|
2024-09-20 08:38:33 -04:00
|
|
|
|
|
|
|
video.onclick = play.onclick = () => {
|
|
|
|
play.querySelector('img').src = !video.paused ? '/static/img/play.svg' : '/static/img/stop.svg';
|
2024-09-19 18:38:24 -04:00
|
|
|
|
|
|
|
if (video.paused) {
|
|
|
|
video.play();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
video.pause();
|
|
|
|
}
|
|
|
|
|
2024-09-22 07:35:03 -04:00
|
|
|
vid.querySelector('.full').onclick = (e) => {
|
|
|
|
isFull = !isFull;
|
|
|
|
e.target.src = isFull ? '/static/img/tiny.svg' : '/static/img/full.svg';
|
|
|
|
if (isFull) {
|
2024-10-25 21:06:23 -04:00
|
|
|
vid.classList.add('full');
|
|
|
|
h.classList.add('full');
|
2024-09-22 07:35:03 -04:00
|
|
|
} else {
|
2024-10-25 21:06:23 -04:00
|
|
|
vid.classList.remove('full');
|
|
|
|
h.classList.remove('full');
|
2024-09-22 07:35:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-19 18:38:24 -04:00
|
|
|
bar.onclick = (e) => moveBar(e, bar, video);
|
|
|
|
|
|
|
|
video.addEventListener('timeupdate', () => prog(video,bar));
|
|
|
|
}
|
|
|
|
|
2024-09-07 18:12:58 -04:00
|
|
|
window.onload = function () {
|
|
|
|
document.addEventListener('submit', formClick);
|
2024-09-20 08:38:33 -04:00
|
|
|
for (let vid of document.querySelectorAll('.video-wrapper')) {
|
2024-09-19 18:38:24 -04:00
|
|
|
controls(vid);
|
|
|
|
}
|
2024-09-07 18:12:58 -04:00
|
|
|
}
|