feat(web): initialize TFM page
Only table of thumbs by now
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
function tdb_query(trdb, trc, trb) {
|
||||
output = null;
|
||||
$.ajax({
|
||||
url: "/TDBMS",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: `{"trdb":"${trdb}","trc":${trc},"trb":"${trb}"}`,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function (resp) {
|
||||
output = resp;
|
||||
},
|
||||
failure: function (err) {
|
||||
alert(err);
|
||||
}
|
||||
});
|
||||
return output;
|
||||
}
|
||||
@@ -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>`);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user