Skip to content

Instantly share code, notes, and snippets.

@hzhangxyz
Last active February 22, 2023 01:56
Show Gist options
  • Save hzhangxyz/0f8da48527b6e357d0487bc128d3f2af to your computer and use it in GitHub Desktop.
Save hzhangxyz/0f8da48527b6e357d0487bc128d3f2af to your computer and use it in GitHub Desktop.
Show all image in a single folder
<div id=container />
<script>
async function getList() {
const resp = await fetch("list.txt", {cache: "no-store"})
const text = await resp.text()
const list = text.split("\n")
return list.filter(name => name.includes(".png"))
}
var container = document.getElementById("container")
var oldList = []
function appendImage(name) {
if (!oldList.includes(name)) {
const image = document.createElement('img')
image.src = name
console.log("append " + name)
container.appendChild(image)
oldList.push(name)
}
}
setInterval(async function() {
const newList = await getList()
newList.forEach(appendImage)
},1000)
</script>
@hzhangxyz
Copy link
Author

hzhangxyz commented Feb 22, 2023

This script is useful when using this index.html

while sleep 2; do find . -printf '%T@ %p\n' | sort | awk '{print $2}' > list.txt; done;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment