Refactor admin
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2021-09-15 18:09:35 +02:00
commit 9d031ea9f9
3 changed files with 87 additions and 24 deletions

View file

@ -16,32 +16,41 @@ function get_picts(then, then_value) {
});
}
function show_mozaic() {
function show_mozaic(callpict) {
if (!picts) {
get_picts(show_mozaic);
get_picts(show_mozaic, callpict);
return;
}
if (!picts.length) {
document.body.innerHTML = '<h1>Welcome on YouP0m!</h1><h2>There is no image currently, come back soon!</h2>';
return;
}
if (!callpict) {
callpict = function (pict) {
var figure = document.createElement("figure");
figure.className = "moz";
var img = document.createElement("img");
img.src = img_url + pict.name;
img.alt = pict.name;
var link = document.createElement("a");
link.onclick = function(e) {
window.history.pushState(null, "YouP0m", link.href);
sync();
return false;
};
link.href = "/" + pict.name;
link.appendChild(img);
figure.appendChild(link);
document.body.appendChild(figure);
}
}
while (document.body.hasChildNodes())
document.body.removeChild(document.body.lastChild);
picts.forEach(function (pict) {
var figure = document.createElement("figure");
figure.className = "moz";
var img = document.createElement("img");
img.src = img_url + pict.name;
img.alt = pict.name;
var link = document.createElement("a");
link.onclick = function(e) {
window.history.pushState(null, "YouP0m", link.href);
sync();
return false;
};
link.href = "/" + pict.name;
link.appendChild(img);
figure.appendChild(link);
document.body.appendChild(figure);
});
picts.forEach(callpict);
}
function show_picture(id) {