feat(web): initialize TFM page

Only table of thumbs by now
This commit is contained in:
2023-01-29 00:45:20 +03:00
parent b55865b8e7
commit 5725015408
5 changed files with 148 additions and 1 deletions
+39
View File
@@ -0,0 +1,39 @@
$(window).on("load", function () {
sasa_load(-1);
})
$(document).keyup(function (e) {
if (e.key === "Escape") {
$(".selected").removeClass("selected");
}
});
$(document).on("click", ".item", function (e) {
let wasSelected = $(this).hasClass("selected");
if (!e.ctrlKey) {
$(".selected").removeClass("selected");
wasSelected = false;
}
if (wasSelected) {
$(this).removeClass("selected");
} else {
$(this).addClass("selected");
}
});
function sasa_load(id) {
resp = tdb_query("$TFM", 16, id < 0 ? "" : `${id}`);
if (resp == null) {
alert("Unauthorized, go to /auth and authorize");
return;
}
if (!resp.status) {
alert("Something went wrong");
return;
}
if (id < 0) {
resp.data.forEach((sasa) => {
$(".contents-wrapper").append(`<div class="item" id="s${sasa.id}" title="${sasa.path.split('/').slice(-1)}" style="background-image: url(${"/thumbs/" + sasa.path})"><div class="overlay"></div></div>`);
});
}
}