This commit is contained in:
Geir Okkenhaug Jerstad 2024-10-24 11:27:53 +02:00
parent c5696e28d1
commit 4ae480551b
9 changed files with 219 additions and 29 deletions

3
morse/controller.js Normal file
View file

@ -0,0 +1,3 @@
function translator(a){
console.log(a);
}

18
morse/index.html Normal file
View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="modell.js"></script>
<script src="controller.js"></script>
<script src="view.js"></script>
</head>
<body>
<div id="app">
<script>updateView()</script>
<input type="text" onchange=""><button onclick="translate()">Button</button>
</div>
</body>
</html>

9
morse/modell.js Normal file
View file

@ -0,0 +1,9 @@
const app = document.getElementById('app')
const morseCodeArray = [ '.-', '-...', '-.-.', '-..', '.', '..-.', '--.', '....', '..', '.---', '-.-', '.-..', '--', '-.', '---', '.--.', '--.-', '.-.', '...', '-', '..-', '...-', '.--', '-..-', '-.--', '--..', ' ', '·−·−', '−−−·', '·−−·−'];
// 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
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Æ Ø Å
const alphabetArray = "abcdefghijklmnopqrstuvwxyz æøå";
let lettersFromInput = " ";
let letterTranslatedToMorse = " ";

7
morse/view.js Normal file
View file

@ -0,0 +1,7 @@
function updateView(){
app.innerHTML = /*html*/ `
<input type="text" onchange="lettersFromInput=this.value"><button onclick="translator(lettersFromInput)">Button</button>
`;
}