You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

embed-editor.html 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Embed collection editor</title>
  7. <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
  8. <link rel="stylesheet" href=
  9. "https://use.fontawesome.com/releases/v5.6.3/css/all.css"
  10. integrity=
  11. "sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/"
  12. crossorigin="anonymous">
  13. <link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
  14. </head>
  15. <body>
  16. <div class="container">
  17. <h1>Embed editor</h1>
  18. <div id='editor_holder'></div>
  19. <div class="btn-group mt-2">
  20. <button class="btn btn-success" id='submit'>Submit</button>
  21. <a class="btn btn-secondary" href="/embeds">Cancel</a>
  22. </div>
  23. </div>
  24. <script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
  25. <script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script>
  26. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
  27. <script>
  28. fetch("/static/embed.schema.json")
  29. .then(res => res.json())
  30. .then(schema => {
  31. console.log(schema)
  32. fetch("/static/media/video-embed.json")
  33. .then(res => res.json())
  34. .then(embeds => {
  35. // Initialize the editor with a JSON schema
  36. var editor = new JSONEditor(
  37. document.getElementById('editor_holder'), {
  38. theme: "bootstrap5",
  39. iconlib: "fontawesome5",
  40. ajax: true,
  41. schema: schema,
  42. startval: embeds
  43. });
  44. // Hook up the submit button to log to the console
  45. document.getElementById('submit').addEventListener('click',() => {
  46. // Get the value from the editor
  47. fetch("/update-embeds", {
  48. method: "POST",
  49. body: JSON.stringify(editor.getValue()),
  50. headers: {
  51. "Content-type": "application/json; charset=UTF-8"
  52. }
  53. }).then((response) => { location.replace('/embeds') });
  54. });
  55. });
  56. });
  57. </script>
  58. </body>
  59. </html>