work ers.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>ACE in Action</title>
  5. <script src="../demo/kitchen-sink/require.js"></script>
  6. <style type="text/css" media="screen">
  7. .editor {
  8. position: relative;
  9. width: 500px;
  10. height: 100px;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <div id="editor-container"></div>
  16. <script>
  17. require.config({
  18. paths: { ace: "../lib/ace" }
  19. })
  20. require(["ace/ace"], function(ace) {
  21. var root = document.getElementById("editor-container")
  22. setInterval(function() {
  23. while (root.firstChild) {
  24. root.firstChild.env.editor.destroy()
  25. root.firstChild.parentNode.removeChild(root.firstChild)
  26. }
  27. for (var i = 0; i < 5; i++) {
  28. var editor = ace.edit(document.createElement("div"))
  29. editor.container.className += " editor"
  30. editor.setOption("mode", "ace/mode/javascript")
  31. editor.setValue("some\ncode\n" + Date.now())
  32. root.appendChild(editor.container)
  33. }
  34. }, 1500);
  35. })
  36. </script>
  37. </body>
  38. </html>