Masonry gallery, add timestamp

This commit is contained in:
JeLuF
2023-08-09 20:02:52 +02:00
parent 1f7c896ad8
commit 87d3e4430e
6 changed files with 64 additions and 35 deletions

View File

@ -3085,13 +3085,25 @@ let recentResolutionsValues = []
})()
/* Gallery JS */
function galleryImage(item) {
let div = document.createElement("div")
let img = document.createElement("img")
img.src = "/image/" + item.path
img.dataset["request"] = JSON.stringify(item)
div.appendChild(img)
return div
}
function refreshGallery() {
let container = document.getElementById("imagecontainer")
container.remove()
container.innerHTML=""
fetch('/all_images')
.then(response => response.text())
.then(text => new DOMParser().parseFromString(text, 'text/html'))
.then(html_like => html_like.getElementsByTagName('div')[0])
.then(div => document.getElementById("tab-content-gallery").appendChild(div))
}
.then(response => response.json())
.then(json => {
console.log(json)
json.forEach( item => {
container.appendChild(galleryImage(item))
})
})
}