editGallery.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Lee Morgan</title>
  6. <style>
  7. form{
  8. display: flex;
  9. flex-direction: column;
  10. }
  11. </style>
  12. </head>
  13. <body>
  14. <form
  15. id="form"
  16. method="post"
  17. enctype="multipart/form-data"
  18. >
  19. <label>Title
  20. <input id="titleInput" name="title" type="text" required>
  21. </label>
  22. <label>Tags
  23. <input id="tagInput" name="tags" type="text" required>
  24. </label>
  25. <label>Location
  26. <input id="locationInput" name="location" type="tags" required>
  27. </label>
  28. <label>New Images
  29. <input name="images" type="file" multiple>
  30. </label>
  31. <input type="submit" value="Submit">
  32. </form>
  33. <script>
  34. let id = window.location.href.split("/");
  35. id = id[id.length-1];
  36. fetch(`/gallery/json/${id}`)
  37. .then(response => response.json())
  38. .then((gallery)=>{
  39. document.getElementById("titleInput").value = gallery.title;
  40. document.getElementById("tagInput").value = gallery.tags.toString();
  41. document.getElementById("locationInput").value = gallery.location.coordinates.toString().replaceAll(",", ", ");
  42. })
  43. .catch((err)=>{console.log(err)});
  44. let form = document.getElementById("form");
  45. </script>
  46. </body>
  47. </html>