summary refs log tree commit diff
path: root/v1.51/book.js
diff options
context:
space:
mode:
authorAction Bot <action@synapse.bot.com>2023-12-11 14:57:16 +0000
committerAction Bot <action@synapse.bot.com>2023-12-11 14:57:16 +0000
commit517770d193922b34d2cd28bda84d7e371c1e2c17 (patch)
treeeca5bee267e67bcc1592053f860c67a9ee277d46 /v1.51/book.js
parentVersion picker deployed for v1.52 docs to Github Pages (diff)
downloadsynapse-517770d193922b34d2cd28bda84d7e371c1e2c17.tar.xz
Version picker deployed for v1.51 docs to Github Pages
Diffstat (limited to 'v1.51/book.js')
-rw-r--r--v1.51/book.js35
1 files changed, 27 insertions, 8 deletions
diff --git a/v1.51/book.js b/v1.51/book.js

index 5e386369f7..d40440c723 100644 --- a/v1.51/book.js +++ b/v1.51/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); });