Added image handling. Scaling. Auto-exec function removed for it is not necessary.
This commit is contained in:
parent
3978f93af2
commit
a3816d6c25
@ -1,32 +1,49 @@
|
|||||||
const video_formats = ["webm", "mp4"];
|
const video_formats = ["webm", "mp4"];
|
||||||
const audio_formats = ["mp3", "flac", "opus", "ogg", "m4a"];
|
const audio_formats = ["mp3", "flac", "opus", "ogg", "m4a"];
|
||||||
|
const image_formats = ["jpg", "jpeg", "gif", "png", "bmp", "webp"];
|
||||||
|
const view_display_style = "flex";
|
||||||
|
|
||||||
(() => {
|
let scale = 1;
|
||||||
document.getElementById("view").addEventListener("click", e => {
|
|
||||||
e.target.firstChild.remove();
|
|
||||||
e.target.style.display = "none";
|
|
||||||
});
|
|
||||||
|
|
||||||
const file_links = Array.from(document.getElementsByTagName('tr')).slice(2).filter((e) => e.lastChild.innerHTML != "DIR").map(v => v.firstChild.firstChild);
|
function mousescroll(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
scale += e.deltaY * -0.001;
|
||||||
|
scale = Math.min(Math.max(0.25, scale), 4);
|
||||||
|
e.target.style.transform = `scale(${scale})`;
|
||||||
|
}
|
||||||
|
|
||||||
file_links.forEach(f => f.addEventListener('click', e => {
|
document.getElementById("view").addEventListener("click", e => {
|
||||||
if (video_formats.some(ext => e.target.pathname.endsWith(ext))) {
|
e.target.firstChild.remove();
|
||||||
e.preventDefault();
|
e.target.style.display = "none";
|
||||||
const video = document.createElement("video");
|
});
|
||||||
video.autoplay = true;
|
|
||||||
video.controls = true;
|
const file_links = Array.from(document.getElementsByTagName('tr')).slice(2).filter((e) => e.lastChild.innerHTML != "DIR").map(v => v.firstChild.firstChild);
|
||||||
video.src = e.target.pathname;
|
|
||||||
document.getElementById("view").appendChild(video);
|
file_links.forEach(f => f.addEventListener('click', e => {
|
||||||
document.getElementById("view").style.display = "flex";
|
if (video_formats.some(ext => e.target.pathname.endsWith(ext))) {
|
||||||
} else if (audio_formats.some(ext => e.target.pathname.endsWith(ext))) {
|
e.preventDefault();
|
||||||
e.preventDefault();
|
const video = document.createElement("video");
|
||||||
const audio = document.createElement("audio");
|
video.addEventListener('wheel', mousescroll);
|
||||||
audio.autoplay = true;
|
video.autoplay = true;
|
||||||
audio.controls = true;
|
video.controls = true;
|
||||||
audio.src = e.target.pathname;
|
video.src = e.target.pathname;
|
||||||
document.getElementById("view").appendChild(audio);
|
document.getElementById("view").appendChild(video);
|
||||||
document.getElementById("view").style.display = "flex";
|
document.getElementById("view").style.display = view_display_style;
|
||||||
}
|
} else if (audio_formats.some(ext => e.target.pathname.endsWith(ext))) {
|
||||||
}));
|
e.preventDefault();
|
||||||
})();
|
const audio = document.createElement("audio");
|
||||||
|
audio.autoplay = true;
|
||||||
|
audio.controls = true;
|
||||||
|
audio.src = e.target.pathname;
|
||||||
|
document.getElementById("view").appendChild(audio);
|
||||||
|
document.getElementById("view").style.display = view_display_style;
|
||||||
|
} else if (image_formats.some(ext => e.target.pathname.endsWith(ext))) {
|
||||||
|
e.preventDefault();
|
||||||
|
const image = document.createElement("img");
|
||||||
|
image.addEventListener('wheel', mousescroll);
|
||||||
|
image.src = e.target.pathname;
|
||||||
|
document.getElementById("view").appendChild(image);
|
||||||
|
document.getElementById("view").style.display = view_display_style;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user