-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
75 lines (73 loc) · 1.84 KB
/
index.html
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<title>NATO Alphabet Converter</title>
</head>
<body>
<h1>NATO Alphabet Converter</h1>
<p>Enter a short text below:</p>
<textarea id="input" rows="4" cols="50"></textarea><br><br>
<button onclick="convertText()">Convert</button><br><br>
<p>Converted text:</p>
<div id="output"></div>
<script>
function convertText() {
var inputText = document.getElementById("input").value.toUpperCase();
var outputDiv = document.getElementById("output");
var natoCodes = {
"A": "Alpha",
"B": "Bravo",
"C": "Charlie",
"D": "Delta",
"E": "Echo",
"F": "Foxtrot",
"G": "Golf",
"H": "Hotel",
"I": "India",
"J": "Juliett",
"K": "Kilo",
"L": "Lima",
"M": "Mike",
"N": "November",
"O": "Oscar",
"P": "Papa",
"Q": "Quebec",
"R": "Romeo",
"S": "Sierra",
"T": "Tango",
"U": "Uniform",
"V": "Victor",
"W": "Whiskey",
"X": "X-ray",
"Y": "Yankee",
"Z": "Zulu",
" ": " <br>",
/*
"0":"0(Zero)",
"1":"1(One)",
"2":"2(Two)",
"3":"3(Three)",
"4":"4(Four)",
"5":"5(Five)",
"6":"6(Six)",
"7":"7(Seven)",
"8":"8(Eight)",
"9":"9(Nine)",
"-":"Dash",
". ":"Stop <br>",
".":"Decimal/Stop" */
};
var outputText = "";
for (var i = 0; i < inputText.length; i++) {
var char = inputText.charAt(i);
if (natoCodes.hasOwnProperty(char)) {
outputText += '<span style="font-weight:bold; color:blue;">' + natoCodes[char].charAt(0) + '</span>' + natoCodes[char].slice(1) + " ";
} else {
outputText += '<span style="font-weight:bold; color:darkblue;">' + char + '</span>'; //+ " ";
}
}
outputDiv.innerHTML = outputText;
}
</script>
</body>
</html>