index.html 4.1 KB

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