diff options
author | johannst <johannst@users.noreply.github.com> | 2022-12-21 22:24:31 +0000 |
---|---|---|
committer | johannst <johannst@users.noreply.github.com> | 2022-12-21 22:24:31 +0000 |
commit | ead2ca2cfa3774af733c613ea03d9b4f3d10fbdf (patch) | |
tree | 495b5de1bd2f37536a471a6ce5b27d8a303e513f /book.js | |
parent | 2dfbc312e6ccb88f838170d8e777d48aacde2ff5 (diff) | |
download | notes-ead2ca2cfa3774af733c613ea03d9b4f3d10fbdf.tar.gz notes-ead2ca2cfa3774af733c613ea03d9b4f3d10fbdf.zip |
deploy: 4a8c8c7520419cbaa01b26353ef35e357c5d1ecf
Diffstat (limited to 'book.js')
-rw-r--r-- | book.js | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -4,14 +4,16 @@ window.onunload = function () { }; // Global variable, shared between modules -function playground_text(playground) { +function playground_text(playground, hidden = true) { let code_block = playground.querySelector("code"); if (window.ace && code_block.classList.contains("editable")) { let editor = window.ace.edit(code_block); return editor.getValue(); - } else { + } else if (hidden) { return code_block.textContent; + } else { + return code_block.innerText; } } @@ -166,7 +168,6 @@ function playground_text(playground) { .filter(function (node) {return node.classList.contains("editable"); }) .forEach(function (block) { block.classList.remove('language-rust'); }); - Array code_nodes .filter(function (node) {return !node.classList.contains("editable"); }) .forEach(function (block) { hljs.highlightBlock(block); }); @@ -300,6 +301,13 @@ function playground_text(playground) { themePopup.querySelector("button#" + get_theme()).focus(); } + function updateThemeSelected() { + themePopup.querySelectorAll('.theme-selected').forEach(function (el) { + el.classList.remove('theme-selected'); + }); + themePopup.querySelector("button#" + get_theme()).classList.add('theme-selected'); + } + function hideThemes() { themePopup.style.display = 'none'; themeToggleButton.setAttribute('aria-expanded', false); @@ -355,6 +363,7 @@ function playground_text(playground) { html.classList.remove(previousTheme); html.classList.add(theme); + updateThemeSelected(); } // Set theme @@ -592,7 +601,7 @@ function playground_text(playground) { text: function (trigger) { hideTooltip(trigger); let playground = trigger.closest("pre"); - return playground_text(playground); + return playground_text(playground, false); } }); |