42 lines
815 B
TypeScript
42 lines
815 B
TypeScript
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
const inputElement = document.getElementById('input')as HTMLFormElement;
|
|
const box = document.getElementById('response_text')as HTMLFormElement;
|
|
const response_text = document.getElementById('response_text')as HTMLFormElement;
|
|
|
|
|
|
|
|
inputElement.addEventListener('keydown', function(event) {
|
|
if (event.key === 'Enter'){
|
|
convert_form();
|
|
}
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function convert_form(): string {
|
|
|
|
const user_input = inputElement.value;
|
|
const converted_user_input = user_input.replace(/ /g, "");
|
|
|
|
box.textContent = converted_user_input;
|
|
|
|
inputElement.value = '';
|
|
|
|
return converted_user_input;
|
|
}
|
|
|
|
|
|
function copy_to_clipboard() {
|
|
const text_to_copy = response_text.textContent;
|
|
|
|
navigator.clipboard.writeText(text_to_copy);
|
|
}
|
|
|
|
|
|
}); |