Skip to content

Instantly share code, notes, and snippets.

@ajp619
Created August 10, 2016 17:15
Show Gist options
  • Save ajp619/b7701917d8a6ac04222cee3dc7be3535 to your computer and use it in GitHub Desktop.
Save ajp619/b7701917d8a6ac04222cee3dc7be3535 to your computer and use it in GitHub Desktop.
Put this in a beaker notebook cell to have a button to run cells of a given tag.
<div>
<button onclick="evaluateTags(this.parentElement)"
style="background-color:lightgreen">Run cells with tag</button>
<!-- SET TAG NAME BELOW: value="tagName" -->
<input type=text value="tagName">
</div>
<script>
function evaluateTags(divElement) {
d3.select(divElement).select("button").attr("style", "background-color:indianred")
d3.select(divElement).selectAll("p").remove()
var tagName = d3.select(divElement).select("input").property("value")
beaker.evaluate(tagName).then(
function(r) {
d3.select(divElement).append("p").html("Output: <br>" + r)
d3.select(divElement).select("button").attr("style", "background-color:lightgreen")
}
)
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment