diff options
author | Action Bot <action@synapse.bot.com> | 2023-12-11 14:56:46 +0000 |
---|---|---|
committer | Action Bot <action@synapse.bot.com> | 2023-12-11 14:56:46 +0000 |
commit | 62f845f9d63713d8232d469f72810dcc53c96ee2 (patch) | |
tree | f75b8c4a06529c524b088f1dc6aa6c17892fae71 /v1.56/book.js | |
parent | Version picker deployed for v1.57 docs to Github Pages (diff) | |
download | synapse-62f845f9d63713d8232d469f72810dcc53c96ee2.tar.xz |
Version picker deployed for v1.56 docs to Github Pages
Diffstat (limited to 'v1.56/book.js')
-rw-r--r-- | v1.56/book.js | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/v1.56/book.js b/v1.56/book.js index 5e386369f7..d40440c723 100644 --- a/v1.56/book.js +++ b/v1.56/book.js @@ -108,9 +108,12 @@ function playground_text(playground) { let text = playground_text(code_block); let classes = code_block.querySelector('code').classList; - let has_2018 = classes.contains("edition2018"); - let edition = has_2018 ? "2018" : "2015"; - + let edition = "2015"; + if(classes.contains("edition2018")) { + edition = "2018"; + } else if(classes.contains("edition2021")) { + edition = "2021"; + } var params = { version: "stable", optimize: "0", @@ -133,7 +136,15 @@ function playground_text(playground) { body: JSON.stringify(params) }) .then(response => response.json()) - .then(response => result_block.innerText = response.result) + .then(response => { + if (response.result.trim() === '') { + result_block.innerText = "No output"; + result_block.classList.add("result-no-output"); + } else { + result_block.innerText = response.result; + result_block.classList.remove("result-no-output"); + } + }) .catch(error => result_block.innerText = "Playground Communication: " + error.message); } @@ -151,12 +162,13 @@ function playground_text(playground) { if (window.ace) { // language-rust class needs to be removed for editable // blocks or highlightjs will capture events - Array - .from(document.querySelectorAll('code.editable')) + code_nodes + .filter(function (node) {return node.classList.contains("editable"); }) .forEach(function (block) { block.classList.remove('language-rust'); }); Array - .from(document.querySelectorAll('code:not(.editable)')) + code_nodes + .filter(function (node) {return !node.classList.contains("editable"); }) .forEach(function (block) { hljs.highlightBlock(block); }); } else { code_nodes.forEach(function (block) { hljs.highlightBlock(block); }); @@ -359,7 +371,14 @@ function playground_text(playground) { }); themePopup.addEventListener('click', function (e) { - var theme = e.target.id || e.target.parentElement.id; + var theme; + if (e.target.className === "theme") { + theme = e.target.id; + } else if (e.target.parentElement.className === "theme") { + theme = e.target.parentElement.id; + } else { + return; + } set_theme(theme); }); |