aboutsummaryrefslogtreecommitdiffhomepage
path: root/book.js
diff options
context:
space:
mode:
authorjohannst <johannst@users.noreply.github.com>2022-12-21 22:24:31 +0000
committerjohannst <johannst@users.noreply.github.com>2022-12-21 22:24:31 +0000
commitead2ca2cfa3774af733c613ea03d9b4f3d10fbdf (patch)
tree495b5de1bd2f37536a471a6ce5b27d8a303e513f /book.js
parent2dfbc312e6ccb88f838170d8e777d48aacde2ff5 (diff)
downloadnotes-ead2ca2cfa3774af733c613ea03d9b4f3d10fbdf.tar.gz
notes-ead2ca2cfa3774af733c613ea03d9b4f3d10fbdf.zip
deploy: 4a8c8c7520419cbaa01b26353ef35e357c5d1ecf
Diffstat (limited to 'book.js')
-rw-r--r--book.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/book.js b/book.js
index d40440c..e303ebb 100644
--- a/book.js
+++ b/book.js
@@ -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);
}
});