WebFM/src/core/static/js/webfm/events.js

102 lines
2.6 KiB
JavaScript
Raw Normal View History

2021-02-06 04:52:46 +00:00
window.onload = (eve) => {
console.log("Loaded...");
}
2021-02-08 02:07:13 +00:00
document.body.onload = (eve) => {
2021-02-08 08:02:14 +00:00
if (window.self !== window.top) {
2021-02-13 11:33:17 +00:00
let elm = document.getElementById("bg");
elm.parentElement.removeChild(elm);
2021-02-08 08:02:14 +00:00
2021-02-13 11:33:17 +00:00
// Stylesheet for iframe views
let link = document.createElement("link");
link.href = "static/css/iframe.css";
link.type = "text/css";
link.rel = "stylesheet";
document.getElementsByTagName("head")[0].appendChild(link);
2021-02-08 08:02:14 +00:00
}
2021-02-13 11:33:17 +00:00
setTimeout(function () {
2023-02-07 03:36:49 +00:00
loadBackground();
2021-02-13 11:33:17 +00:00
getFavesAjax();
reloadDirectory();
2021-09-28 22:37:20 +00:00
}, 400);
2021-02-08 02:07:13 +00:00
}
2021-02-08 07:15:38 +00:00
const loadFavePath = (e) => {
const target = e.target;
const faveId = target.getAttribute("faveid");
loadFavorite(faveId);
}
2021-02-08 07:15:38 +00:00
const openFile = (eve) => {
2021-02-21 20:20:45 +00:00
let target = eve.target;
if (!target.getAttribute("title"))
target = target.parentElement
const ftype = target.getAttribute("ftype");
const title = target.getAttribute("title");
const hash = target.getAttribute("hash");
const parts = title.split('.');
const extension = "." + parts[parts.length - 1].toLowerCase();
if (ftype === "dir") {
listFilesAjax(hash);
} else if (ftype === "video") {
showFile(title, hash, extension, "video", target);
} else {
2021-02-18 01:28:53 +00:00
showFile(title, hash, extension, "file");
}
2021-02-08 07:15:38 +00:00
}
const openFileLocally = (eve) => {
const target = eve.target;
const hash = target.getAttribute("hash");
2021-02-08 08:02:14 +00:00
openWithLocalProgram(hash);
2021-02-08 07:15:38 +00:00
}
2023-02-07 03:36:49 +00:00
// Background control events
$( "#background-selection" ).bind( "click", async function(eve) {
const target = eve.target;
if (target.className === "bg-imgs") {
const path = (!target.src.endsWith("/")) ? target.src : target.poster;
setBackgroundCookie(path);
}
});
2023-02-07 03:36:49 +00:00
$( "#load-bglist-btn" ).bind( "click", async function(eve) {
getBackgrounds();
});
$( "#search-files-field").bind( "keyup", async function(eve) {
2021-02-08 07:15:38 +00:00
searchPage();
});
$( "#clear-search-btn").bind( "click", async function(eve) {
2021-02-08 07:15:38 +00:00
clearSearch();
});
$( "#refresh-btn").bind( "click", async function(eve) {
2021-02-08 07:15:38 +00:00
reloadDirectory();
});
$( "#back-btn").bind( "click", async function(eve) {
2021-02-08 07:15:38 +00:00
goUpADirectory();
});
$( "#tggl-faves-btn").bind( "click", async function(eve) {
2021-02-08 07:15:38 +00:00
manageFavorites(eve.target);
});
$( "#scroll-files-to-top-btn").bind( "click", async function(eve) {
2021-02-08 07:15:38 +00:00
scrollFilesToTop();
});
$( "#playlist-mode-btn").bind( "click", async function(eve) {
togglePlaylistMode(eve.target);
});
$( "#close-file-modal-btn").bind( "click", async function(eve) {
closeFile();
});