Skip to content

Commit

Permalink
Add hide function ability
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelafox committed Aug 3, 2024
1 parent 483a75b commit e2772c2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<div class="container">

<h1>Visualize a recursive function</h1>
<div id="function-code-container">
<label>Try one of these functions:
<select id="function-select">
<option value="none">Choose one...</option>
Expand All @@ -42,6 +43,8 @@ <h1>Visualize a recursive function</h1>
<br>
<br>
<button id="visualize-button" type="button" class="btn btn-primary" disabled>Visualize!</button>
</div>

<span id="visualize-status">Loading libraries...</span>
<pre style="display:none" id="virfib-definition">
def virfib(n):
Expand Down Expand Up @@ -100,6 +103,8 @@ <h1>Visualize a recursive function</h1>

<div id="permalink-area" style="margin-top:12px; display:none;">
<label for="permalink-input">Permalink:</label> <input type="url" id="permalink-input" style="width: 600px;">
<br>
Tip: Add &hide_function=true to hide the function code.
</div>

<div style="margin-top:80px;">
Expand Down Expand Up @@ -132,8 +137,10 @@ <h1>Visualize a recursive function</h1>
const urlParams = new URLSearchParams(window.location.search);
const funcDef = urlParams.get('function_definition');
const funcCall = urlParams.get('function_call');
const hideFunc = urlParams.get('hide_function');
if (funcDef) document.getElementById('function-definition-textarea').value = funcDef;
if (funcCall) document.getElementById('function-call-input').value = funcCall;
if (hideFunc == 'true') document.getElementById('function-code-container').style.display = "none";
const readyToViz = funcDef && funcCall;
</script>
<!-- Python callgraph computation + Graphviz rendering-->
Expand Down

0 comments on commit e2772c2

Please sign in to comment.