Skip to content

Commit

Permalink
Disable parse iocs button until page loads
Browse files Browse the repository at this point in the history
  • Loading branch information
fhightower committed Nov 16, 2023
1 parent 4532052 commit 06ae551
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ Enter some text with IOCs here and click "Parse IOCs" to see how ioc-finder pars
<textarea id="iocText" placeholder="">Test 1, 2, 3 foobar.com https://example.org/test/bingo.php
1.1.1.1 2.2.2.2222</textarea>
<button class="md-button md-button--primary" id="parseButton" onclick="parseIOCs()" disabled=true>Parse IOCs!</button>
<button class="md-button" onclick="reload()">Reload</button>
<button class="md-button md-button--primary" id="parseButton" onclick="parseIOCs()" disabled=true>&#x231B;</button>
<button class="md-button" id="reloadButton" onclick="reload()">Reload</button>
<br>
<pre id="output" style="white-space: pre-wrap;"></pre>

Expand Down
25 changes: 23 additions & 2 deletions docs/overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@
<script>
"use strict";
var pyodide = undefined;

function disableButton() {
console.log("disable");
const button = document.getElementById('parseButton');
if (button != null) {
console.log("found button");
button.disabled = true;
button.innerHTML = '&#x231B;';
}
}

function enableButton() {
console.log("enable");
const button = document.getElementById('parseButton');
button.disabled = false;
button.innerHTML = 'Parse IOCs!';
}

async function main() {
pyodide = await loadPyodide();
await pyodide.loadPackage("micropip");
Expand All @@ -24,12 +42,15 @@
await pyodide.runPython("from ioc_finder import find_iocs");

pyodide.runPython("print('ioc-finder succesfully installed 🎉')");
document.getElementById('parseButton').disabled = false;
enableButton();
document.getElementById('reloadButton').disabled = false;
}
disableButton();
main();

async function reload() {
document.getElementById('parseButton').disabled = true;
disableButton();
document.getElementById('reloadButton').disabled = true;
document.getElementById('output').innerHTML = '';
document.getElementById('iocText').focus();
main();
Expand Down

0 comments on commit 06ae551

Please sign in to comment.