2024-07-21 09:47:28 -07:00
|
|
|
function toggleDarkMode() {
|
|
|
|
|
document.body.classList.toggle("dark");
|
2026-03-30 17:44:19 -07:00
|
|
|
const currentCSS = document.getElementById("highlight-css");
|
2024-07-21 09:47:28 -07:00
|
|
|
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-08 17:34:56 -07:00
|
|
|
|
|
|
|
|
// Re-highlight all code blocks once stylesheet loads
|
|
|
|
|
currentCSS.onload = function() {
|
2026-03-30 17:44:19 -07:00
|
|
|
// Clear data-highlighted so hljs will re-process with the new theme
|
|
|
|
|
document.querySelectorAll("#chat .message-body pre code[data-highlighted]").forEach((codeBlock) => {
|
|
|
|
|
delete codeBlock.dataset.highlighted;
|
2025-06-08 17:34:56 -07:00
|
|
|
});
|
2026-03-30 17:44:19 -07:00
|
|
|
doSyntaxHighlighting();
|
2025-06-08 17:34:56 -07:00
|
|
|
};
|
2024-07-21 09:47:28 -07:00
|
|
|
}
|