editGallery.html 1.9 KB

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