diff --git a/views/js/illust-preview.js b/views/js/illust-preview.js new file mode 100644 index 0000000..2309bba --- /dev/null +++ b/views/js/illust-preview.js @@ -0,0 +1,53 @@ +function OpenPreviewer(url) { + const viewer = document.createElement("div"); + viewer.style.cssText = ` + height: 100vh; + width: 100vw; + position: fixed; + top: 0; + left: 0; + background: rgba(0,0,0,.8); + display: flex; +flex-direction: column; + padding: 0 3rem; + overflow: scroll; + `; + + const image = url.replace(/c\/\d+x\d+.*?\//, "").replace(/square1200/, "master1200"); + const img = document.createElement("img"); + img.src = image; + img.style.cssText = ` + margin: 3rem auto; + max-width: 90%; + max-height: 90%; + ` + + viewer.appendChild(img); + + document.body.appendChild(viewer); + + viewer.onclick = () => { + document.body.removeChild(viewer); + }; +} + +function Overlay() { + document.querySelectorAll('.artwork-small img').forEach(illust => { + const url = illust.getAttribute("src"); + const button = document.createElement('div'); + button.style.cssText = ` + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + `; + illust.parentElement.parentElement.appendChild(button); + button.onclick = (e) => { + OpenPreviewer(url); + }; + }) + console.log("ran") +} + +Overlay(); diff --git a/views/pages/_layout.jet.html b/views/pages/_layout.jet.html index 92daeaf..68ca0d4 100644 --- a/views/pages/_layout.jet.html +++ b/views/pages/_layout.jet.html @@ -16,6 +16,8 @@ + + @@ -103,4 +105,4 @@ - \ No newline at end of file +