text-generation-webui/js/dark_theme.js

19 lines
750 B
JavaScript
Raw Normal View History

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");
}
// 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;
});
2026-03-30 17:44:19 -07:00
doSyntaxHighlighting();
};
2024-07-21 09:47:28 -07:00
}