Add a clear button
continuous-integration/drone/push Build is passing Details

main
Clément FRÉVILLE 9 months ago
parent 6a5888640c
commit 947b539b1d

@ -9,10 +9,13 @@
</head> </head>
<body> <body>
<div id="app"> <div id="app">
<div class="input">
<input type="text" id="word-input" autocapitalize="off" spellcheck="false" /> <input type="text" id="word-input" autocapitalize="off" spellcheck="false" />
<div id="light"></div>
</div>
<div class="input"> <div class="input">
<div id="input-buttons"></div> <div id="input-buttons"></div>
<div id="light"></div> <button id="clear-button">Clear</button>
</div> </div>
<pre id="pen"></pre> <pre id="pen"></pre>
<pre id="state-graph"></pre> <pre id="state-graph"></pre>

@ -6,6 +6,7 @@ const IS_INVALID = 'is-invalid';
const wordInput = /** @type {HTMLInputElement} */ (document.getElementById('word-input')); const wordInput = /** @type {HTMLInputElement} */ (document.getElementById('word-input'));
const buttons = /** @type {HTMLDivElement} */ (document.getElementById('input-buttons')); const buttons = /** @type {HTMLDivElement} */ (document.getElementById('input-buttons'));
const clearButton = /** @type {HTMLButtonElement} */ (document.getElementById('clear-button'));
const light = /** @type {HTMLDivElement} */ (document.getElementById('light')); const light = /** @type {HTMLDivElement} */ (document.getElementById('light'));
mermaid.initialize({ mermaid.initialize({
@ -80,7 +81,6 @@ for (const letter of alphabet) {
// Reacts to input in the text box // Reacts to input in the text box
wordInput.addEventListener('input', () => { wordInput.addEventListener('input', () => {
const value = wordInput.value; const value = wordInput.value;
console.log(value);
builder = ''; builder = '';
state = 0; state = 0;
for (const letter of value) { for (const letter of value) {
@ -91,4 +91,11 @@ wordInput.addEventListener('input', () => {
} }
}); });
clearButton.addEventListener('click', () => {
wordInput.value = '';
builder = '';
state = 0;
updateUIState();
});
updateUIState(); updateUIState();

@ -36,10 +36,10 @@ h1 {
.input { .input {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 0.5em;
} }
input { input {
padding: 0.3em 0.5em; padding: 0.3em 0.5em;
margin-bottom: 0.5em;
font-size: 1.1em; font-size: 1.1em;
width: 6em; width: 6em;
background-color: transparent; background-color: transparent;

Loading…
Cancel
Save