index.html 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Lee Morgan -gallery-</title>
  6. <link rel="stylesheet" href="/gallery/style">
  7. </head>
  8. <body>
  9. <h1 id="title"></h1>
  10. <div id="tags"></div>
  11. <div id="images"></div>
  12. <div id="fullPage" style="display:none">
  13. <svg id="closeImg" width="50" height="50" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
  14. <line x1="18" y1="6" x2="6" y2="18"></line>
  15. <line x1="6" y1="6" x2="18" y2="18"></line>
  16. </svg>
  17. <svg id="nextImg" width="50" height="50" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
  18. <line x1="5" y1="12" x2="19" y2="12"></line>
  19. <polyline points="12 5 19 12 12 19"></polyline>
  20. </svg>
  21. <svg id="previousImg" width="50" height="50" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
  22. <line x1="19" y1="12" x2="5" y2="12"></line>
  23. <polyline points="12 19 5 12 12 5"></polyline>
  24. </svg>
  25. </div>
  26. <script>
  27. let id = window.location.pathname.split("/");
  28. id = id[id.length-1];
  29. window.imageIndex = 0;
  30. let fullPage = document.getElementById("fullPage");
  31. let container = document.getElementById("images");
  32. fetch(`/gallery/json/${id}`)
  33. .then(response => response.json())
  34. .then((response)=>{
  35. document.getElementById("title").innerText = response.title;
  36. let tags = document.getElementById("tags");
  37. for(let i = 0; i < response.tags.length; i++){
  38. let tag = document.createElement("p");
  39. tag.innerText = response.tags[i];
  40. tag.classList.add("tag");
  41. tags.appendChild(tag);
  42. }
  43. for(let i = 0; i < response.images.length; i++){
  44. let img = document.createElement("img");
  45. img.src = response.images[i];
  46. img.alt = "Missing image";
  47. img.onclick = ()=>{
  48. imageIndex = i;
  49. let newImg = img.cloneNode(true);
  50. fullPage.appendChild(newImg);
  51. fullPage.style.display = "flex";
  52. newImg.onclick = ()=>{event.stopPropagation()};
  53. }
  54. container.appendChild(img);
  55. }
  56. })
  57. .catch((err)=>{});
  58. document.getElementById("fullPage").onclick = ()=>{
  59. fullPage.removeChild(document.querySelector("#fullPage img"));
  60. fullPage.style.display = "none";
  61. };
  62. document.getElementById("nextImg").onclick = ()=>{
  63. event.stopPropagation();
  64. if(imageIndex >= container.children.length - 1) return;
  65. imageIndex++;
  66. let newImg = container.children[imageIndex].cloneNode(true);
  67. newImg.onclick = ()=>{event.stopPropagation()};
  68. fullPage.removeChild(document.querySelector("#fullPage img"));
  69. fullPage.appendChild(newImg);
  70. }
  71. document.getElementById("previousImg").onclick = ()=>{
  72. event.stopPropagation();
  73. if(imageIndex <= 0) return;
  74. imageIndex--;
  75. let newImg = container.children[imageIndex].cloneNode(true);
  76. newImg.onclick = ()=>{event.stopPropagation()};
  77. fullPage.removeChild(document.querySelector("#fullPage img"));
  78. fullPage.appendChild(newImg);
  79. }
  80. </script>
  81. </body>
  82. </html>