Ein für Shopware 6 vorbereitet Systemmanagment.
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.

38 lines
1.1 KiB

1 year ago
  1. import("https://cdn.jsdelivr.net/npm/marked/marked.min.js");
  2. function include(element, file) {
  3. if (file) {
  4. const xhttp = new XMLHttpRequest();
  5. xhttp.onreadystatechange = function () {
  6. if (this.readyState == 4) {
  7. if (this.status == 200) {
  8. if ('.md' == file.match(/\.md$/)) {
  9. element.innerHTML = marked.parse(this.responseText);
  10. } else {
  11. element.innerHTML = this.responseText;
  12. }
  13. }
  14. if (this.status == 404) {
  15. element.innerHTML = "Page not found.";
  16. }
  17. }
  18. }
  19. xhttp.open("GET", file, true);
  20. xhttp.send();
  21. }
  22. }
  23. function parseIncludes()
  24. {
  25. const elements = document.querySelectorAll('div[include$=".html"]');
  26. elements.forEach((element) => {
  27. include(element, element.getAttribute('include'));
  28. });
  29. }
  30. function page(file) {
  31. include(document.getElementById('page'), file);
  32. }
  33. document.addEventListener('DOMContentLoaded', () => {
  34. parseIncludes();
  35. });