2024-07-21 18:47:28 +02:00
|
|
|
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");
|
|
|
|
|
}
|
2025-06-09 02:34:56 +02:00
|
|
|
|
|
|
|
|
// Re-highlight all code blocks once stylesheet loads
|
|
|
|
|
currentCSS.onload = function() {
|
2025-06-10 03:40:54 +02:00
|
|
|
const messageBodies = document.getElementById("chat").querySelectorAll(".message-body");
|
|
|
|
|
messageBodies.forEach((messageBody) => {
|
|
|
|
|
const codeBlocks = messageBody.querySelectorAll("pre code");
|
|
|
|
|
codeBlocks.forEach((codeBlock) => {
|
|
|
|
|
hljs.highlightElement(codeBlock);
|
|
|
|
|
});
|
2025-06-09 02:34:56 +02:00
|
|
|
});
|
|
|
|
|
};
|
2024-07-21 18:47:28 +02:00
|
|
|
}
|