Changed textbot to text only. Updated logic as well.
This commit is contained in:
@@ -46,22 +46,22 @@ hashBtn.addEventListener('click', async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
result.value = data.hash;
|
result.textContent = data.hash;
|
||||||
});
|
});
|
||||||
|
|
||||||
clearBtn.addEventListener('click', () => {
|
clearBtn.addEventListener('click', () => {
|
||||||
password.value = '';
|
password.value = '';
|
||||||
salt.value = '';
|
salt.value = '';
|
||||||
result.value = '';
|
result.textContent = 'Result will appear here';
|
||||||
});
|
});
|
||||||
|
|
||||||
resultBtn.addEventListener('click', async () => {
|
resultBtn.addEventListener('click', async () => {
|
||||||
if (!result.value) {
|
if (!result.textContent || result.textContent === 'Result will appear here') {
|
||||||
alert('Nothing to copy.');
|
alert('Nothing to copy.');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(result.value);
|
await navigator.clipboard.writeText(result.textContent);
|
||||||
alert('Copied to clipboard.');
|
alert('Copied to clipboard.');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('Failed to copy: ' + err);
|
alert('Failed to copy: ' + err);
|
||||||
|
|||||||
@@ -37,9 +37,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<label for="result">Result</label>
|
<label>Result</label>
|
||||||
|
<pre id="result" class="result-box">Result will appear here</pre>
|
||||||
<button id="resultBtn" type="button">Copy result</button>
|
<button id="resultBtn" type="button">Copy result</button>
|
||||||
<textarea id="result" rows="4" readonly placeholder="Result will appear here"></textarea>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/main.js"></script>
|
<script src="/static/js/main.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user