text-generation-webui/js/dark_theme.js

17 lines
595 B
JavaScript
Raw Normal View History

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");
}
// Re-highlight all code blocks once stylesheet loads
currentCSS.onload = function() {
document.querySelectorAll("pre code").forEach(block => {
hljs.highlightElement(block);
});
};
2024-07-21 18:47:28 +02:00
}