editGallery.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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>Uploader
  20. <input name="uploader" type="text" required>
  21. </label>
  22. <label>Password
  23. <input name="password" type="password" required>
  24. </label>
  25. <label>Title
  26. <input id="titleInput" name="title" type="text" required>
  27. </label>
  28. <label>Tags
  29. <input id="tagInput" name="tags" type="text" required>
  30. </label>
  31. <label>Location
  32. <input id="locationInput" name="location" type="tags" required>
  33. </label>
  34. <label>New Images
  35. <input name="images" type="file" multiple>
  36. </label>
  37. <input type="submit" value="Submit">
  38. </form>
  39. <script>
  40. let id = window.location.href.split("/");
  41. id = id[id.length-1];
  42. fetch(`/gallery/json/${id}`)
  43. .then(response => response.json())
  44. .then((gallery)=>{
  45. document.getElementById("titleInput").value = gallery.title;
  46. document.getElementById("tagInput").value = gallery.tags.toString();
  47. document.getElementById("locationInput").value = gallery.location.coordinates.toString().replaceAll(",", ", ");
  48. })
  49. .catch((err)=>{});
  50. let form = document.getElementById("form");
  51. form.action = `/gallery/update/${id}`;
  52. </script>
  53. </body>
  54. </html>