Rebuilding the Machine Listening Curriculum beginning in 2024
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.

159 regels
4.6 KiB

  1. window.addEventListener("scroll", function (e) {
  2. if (document.querySelector("body").clientWidth > 767) {
  3. let rightcolumn = document.querySelector(".rightcolumn");
  4. let mantletitle =
  5. document.querySelector(".mantletitle") ||
  6. document.querySelector(".crusttitle") ||
  7. false;
  8. if (!mantletitle) {
  9. return;
  10. }
  11. let mantlebar = document.querySelector(".mantlebar");
  12. let grid = document.querySelector(".grid");
  13. let gridrect = mantletitle.getBoundingClientRect();
  14. if (
  15. document.querySelector("body").clientHeight -
  16. (grid.clientHeight + mantletitle.clientHeight + 32) <
  17. window.innerHeight
  18. ) {
  19. return;
  20. }
  21. if (gridrect.top < 20 && !grid.classList.contains("moved")) {
  22. grid.classList.add("moved");
  23. mantlebar.style.display = "inline";
  24. mantletitle.style.visibility = "hidden";
  25. } else if (gridrect.top > 21 && grid.classList.contains("moved")) {
  26. grid.classList.remove("moved");
  27. mantletitle.style.visibility = "visible";
  28. mantlebar.style.display = "none";
  29. }
  30. } else {
  31. let rightcolumn = document.querySelector(".rightcolumn");
  32. let mantletitle =
  33. document.querySelector(".mantletitle") ||
  34. document.querySelector(".crusttitle") ||
  35. false;
  36. if (!mantletitle) {
  37. return;
  38. }
  39. let mantlebar = document.querySelector(".mantlebar");
  40. let grid = document.querySelector(".grid");
  41. let gridrect = mantletitle.getBoundingClientRect();
  42. if (gridrect.top < 20 && !grid.classList.contains("moved")) {
  43. grid.classList.add("moved");
  44. mantlebar.style.display = "inline";
  45. mantletitle.style.visibility = "hidden";
  46. } else if (gridrect.top > 21 && grid.classList.contains("moved")) {
  47. grid.classList.remove("moved");
  48. mantletitle.style.visibility = "visible";
  49. mantlebar.style.display = "none";
  50. }
  51. }
  52. });
  53. function editPage(repoJsId) {
  54. let relPath = "../".repeat(relPathDepth - 1);
  55. var el = document.createElement('script');
  56. el.onload = ()=> {
  57. console.log("loading...")
  58. console.log(repo)
  59. }
  60. el.src = `${relPath}js/repo/${repoJsId}.js`
  61. document.body.appendChild(el)
  62. document.location.href = `${relPath}edit/index.html?edit=${repoJsId}`
  63. ev}
  64. window.addEventListener("keyup", (e)=> {
  65. if (e.key == "e" && location.protocol == "file:") {
  66. editPage(sandpointsPageId)
  67. } else if (e.key == "E" && location.protocol == "file:") {
  68. let preview = document.querySelector("#preview");
  69. if (preview.style.display == "flex") {
  70. preview.style.display = "none";
  71. } else {
  72. preview.style.display = "flex";
  73. }
  74. console.log("preview: ", preview);
  75. }
  76. })
  77. window.addEventListener("DOMContentLoaded", (e) => {
  78. if (location.protocol == "file:") {
  79. document.querySelectorAll(".svedit").forEach((i) => {
  80. i.style.display = "inline";
  81. })
  82. }
  83. document.querySelectorAll('.triadlink').forEach((i) => {
  84. i.addEventListener("click", (ev) => {
  85. if (ev.ctrlKey) {
  86. ev.preventDefault()
  87. editPage(ev.target.getAttribute("repoid"))
  88. }
  89. })
  90. })
  91. let preview = document.querySelector("#preview");
  92. if (
  93. location.pathname.split("/").includes("_preview") ||
  94. location.hash.startsWith("#/_edit")
  95. ) {
  96. preview.style.display = "flex";
  97. }
  98. let par = document.querySelector(
  99. "#TableOfContents > ol:first-child > li:first-child"
  100. );
  101. if (par) {
  102. let s = document.createElement("span");
  103. s.appendChild(par.cloneNode(true));
  104. par.remove();
  105. document
  106. .querySelector("#TableOfContents > ol:first-child")
  107. .insertBefore(
  108. s,
  109. document.querySelector("#TableOfContents > ol:first-child").firstChild
  110. );
  111. }
  112. if (document.querySelector(".soundcite")) {
  113. let relPath = "../".repeat(relPathDepth - 1);
  114. var popcorn = document.createElement("script");
  115. popcorn.src = `${relPath}js/popcorn.min.js`;
  116. document.body.appendChild(popcorn);
  117. var soundcite = document.createElement("script");
  118. soundcite.src = `${relPath}js/soundcite.min.js`;
  119. document.body.appendChild(soundcite);
  120. }
  121. document
  122. .querySelectorAll(
  123. "#TableOfContents a, .anchorz, .footnote-backref, .footnote-ref"
  124. )
  125. .forEach((i) => {
  126. i.addEventListener("click", (e) => {
  127. setTimeout(() => {
  128. window.scrollBy({
  129. top: document.querySelector(".header").clientHeight * -1.25,
  130. behavior: "smooth",
  131. });
  132. }, 50);
  133. });
  134. });
  135. });
  136. toggleAllLinks = function () {
  137. document.querySelectorAll("details").forEach((i) => {
  138. if (i.open) {
  139. i.removeAttribute("open");
  140. } else {
  141. i.setAttribute("open", true);
  142. }
  143. });
  144. };