Skip to content

Commit

Permalink
Un-hide TryExamples buttons based on regex
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed May 1, 2024
1 parent 37fa0ca commit 09d48ab
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions jupyterlite_sphinx/jupyterlite_sphinx.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,18 @@ window.loadTryExamplesConfig = async (configFilePath) => {
tryExamplesGlobalMinHeight = parseInt(data.global_min_height);
}

// Disable interactive examples if file matches one of the ignore patterns
// by hiding try_examples_buttons.
// Selectively enable interactive examples if file matches one of the ignore patterns
// by un-hiding try_examples_buttons.
Patterns = data.ignore_patterns;
for (let pattern of Patterns) {
let regex = new RegExp(pattern);
if (regex.test(currentPageUrl)) {
var buttons = document.getElementsByClassName("try_examples_button");
if (!regex.test(currentPageUrl)) {
var buttons = document.getElementsByClassName(
"try_examples_button hidden",
);
for (var i = 0; i < buttons.length; i++) {
buttons[i].classList.add("hidden");
console.log(buttons[i]);
buttons[i].classList.remove("hidden");
}
break;
}
Expand Down

0 comments on commit 09d48ab

Please sign in to comment.