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

83 lines
2.0 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 () {
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") {
2021-02-18 01:28:53 +00:00
showFile(title, hash, extension, "video");
} 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
}
2021-02-08 07:15:38 +00:00
$( "#search-files-field" ).bind( "keyup", async function(eve) {
searchPage();
});
$( "#clear-search-btn" ).bind( "click", async function(eve) {
clearSearch();
});
$( "#refresh-btn" ).bind( "click", async function(eve) {
reloadDirectory();
});
$( "#back-btn" ).bind( "click", async function(eve) {
goUpADirectory();
});
$( "#tggl-faves-btn" ).bind( "click", async function(eve) {
manageFavorites(eve.target);
});
$( "#scroll-files-to-top-btn" ).bind( "click", async function(eve) {
scrollFilesToTop();
});