Spaces:
Paused

File size: 797 Bytes
aea84cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function toggleDarkMode() {
  document.body.classList.toggle("dark");
  var currentCSS = document.getElementById("highlight-css");
  if (currentCSS.getAttribute("href") === "file/css/highlightjs/github-dark.min.css") {
    currentCSS.setAttribute("href", "file/css/highlightjs/github.min.css");
  } else {
    currentCSS.setAttribute("href", "file/css/highlightjs/github-dark.min.css");
  }

  // Re-highlight all code blocks once stylesheet loads
  currentCSS.onload = function() {
    const messageBodies = document.getElementById("chat").querySelectorAll(".message-body");
    messageBodies.forEach((messageBody) => {
      const codeBlocks = messageBody.querySelectorAll("pre code");
      codeBlocks.forEach((codeBlock) => {
        hljs.highlightElement(codeBlock);
      });
    });
  };
}