Debian Codegraph @

inst/misc/toggleR.js

raw symbols SCIP
1 // toggle visibility of R source blocks in R Markdown output
2 (d => {
3 d.insertAdjacentHTML('beforeend','<button style="position:absolute;top:0;right:0;z-index:2;">Toggle Source</button>');
4 d.lastElementChild.onclick = (e) => {
5 d.querySelectorAll('pre.r').forEach(el => {
6 el.style.display = (el.style.display === 'none') ? 'block' : 'none';
7 });
8 };
9 })(document.body);