index.html 3.8 KB

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