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.

chat-editor.html 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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>Themed chat 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>Themed chat 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="/example">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/chat.schema.json")
  29. .then(res => res.json())
  30. .then(schema => {
  31. fetch("/static/chat-example.json")
  32. .then(res => res.json())
  33. .then(slides => {
  34. // Initialize the editor with a JSON schema
  35. var editor = new JSONEditor(
  36. document.getElementById('editor_holder'), {
  37. theme: "bootstrap5",
  38. iconlib: "fontawesome5",
  39. ajax: true,
  40. schema: schema,
  41. startval: slides
  42. });
  43. // Hook up the submit button to log to the console
  44. document.getElementById('submit').addEventListener('click',() => {
  45. // Get the value from the editor
  46. fetch("/update-chat", {
  47. method: "POST",
  48. body: JSON.stringify(editor.getValue()),
  49. headers: {
  50. "Content-type": "application/json; charset=UTF-8"
  51. }
  52. }).then((response) => { location.replace('/example') });
  53. });
  54. });
  55. });
  56. </script>
  57. </body>
  58. </html>