igar/static/main.js

51 lines
1.3 KiB
JavaScript

function addimages(list, s) {
let cont = document.querySelector("main");
if (list) {
list.forEach((image, i) => {
let url = "img/" + image.post;
if (image.hidden != true) {
let a = document.createElement("a");
a.setAttribute("href", "view?uuid=" + image.post);
let img = document.createElement("img");
img.setAttribute("class", "thumb");
img.setAttribute("alt", image.post);
img.setAttribute("src", url + "/thumb.jpg");
a.appendChild(img);
if (image.media.length > 1) {
let type = document.createElement("img");
type.setAttribute("class", "type");
type.setAttribute("alt", "galería");
type.setAttribute("src", "static/gallery.png");
a.appendChild(type);
} else if (image.media[0].type == "GraphVideo") {
let type = document.createElement("img");
type.setAttribute("class", "type");
type.setAttribute("alt", "video");
type.setAttribute("src", "static/video.png");
a.appendChild(type);
}
a.setAttribute("onclick", `window.app.store()`);
a.setAttribute("class", "elem");
cont.appendChild(a);
}
});
}
return !list;
}
window.onload = () => {
window.app = new ProgView(addimages);
window.app.down();
};
window.onbeforeunload = () => {
if (!window.app.stored) {
window.app.clear();
}
};