Debian Codegraph @

jupyter_sphinx/thebelab/thebelab-helper.js

raw
1 function initThebelab() {
2 let activateButton = document.getElementById("thebelab-activate-button");
3 if (activateButton.classList.contains('thebelab-active')) {
4 return;
5 }
6
7 // Place all outputs below the source where this was not the case
8 // to make them recognizable by thebelab
9 let codeBelows = document.getElementsByClassName('thebelab-below');
10 for(var i = 0; i < codeBelows.length; i++) {
11 let prev = codeBelows[i]
12 // Find previous sibling element, compatible with IE8
13 do prev = prev.previousSibling; while(prev && prev.nodeType !== 1);
14 swapSibling(prev, codeBelows[i])
15 }
16
17 thebelab.bootstrap();
18 activateButton.classList.add('thebelab-active')
19 }
20
21 function swapSibling(node1, node2) {
22 node1.parentNode.replaceChild(node1, node2);
23 node1.parentNode.insertBefore(node2, node1);
24 }