-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
31 lines (29 loc) · 993 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { convertToEng, convertToMorse } from './conversionFunctions.js';
const englishBox = document.getElementById('english');
const morseBox = document.getElementById('morse');
const morseCopy = document.getElementById('morseCopy');
const englishCopy = document.getElementById('englishCopy');
morseCopy.addEventListener('click', () => {
navigator.clipboard.writeText(morseBox.value);
morseCopy.style.opacity = 0.5;
setTimeout(() => {
morseCopy.style.opacity = 1;
}, 100);
});
englishCopy.addEventListener('click', () => {
navigator.clipboard.writeText(englishBox.value);
englishCopy.style.opacity = 0.5;
setTimeout(() => {
englishCopy.style.opacity = 1;
}, 100);
});
englishBox.addEventListener('keypress', function enterPress(e) {
if (e.which == 13) {
morseBox.value = convertToMorse(englishBox.value);
}
});
morseBox.addEventListener('keypress', function enterPress(e) {
if (e.which == 13) {
englishBox.value = convertToEng(morseBox.value);
}
});