Skip to content

Instantly share code, notes, and snippets.

@kaa
Created January 22, 2022 13:16
Show Gist options
  • Save kaa/a746782affed4745fcf7d3c154d9d6d7 to your computer and use it in GitHub Desktop.
Save kaa/a746782affed4745fcf7d3c154d9d6d7 to your computer and use it in GitHub Desktop.
Grid
<html style="background:black">
<textarea id="input"></textarea><br>
<img style="position: absolute; top: 0; left: 50%; transform: translateX(-50%); max-height: 100vh; max-width: 100vw" id="grid">
<script>
grid = document.getElementById("grid")
area = document.getElementById("input")
area.addEventListener("change", function(){
i = 0;
items = area.value.split("\n").map(t => t.replace("/small/","/big/").replace("/thumbs","/img").replace("_t.","."));
update();
})
document.body.addEventListener("keyup", function(evt) {
i += (evt.key=="ArrowLeft" ? -1 : evt.key=="ArrowRight" ? 1 : 0) * (evt.shiftKey ? 10 : 1);
update();
})
function update() {
grid.setAttribute("src", "")
grid.setAttribute("src", items[i])
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment