mirror of
https://github.com/seigler/natospell
synced 2025-07-27 00:56:10 +00:00
chore: reorg, too simple to need a src folder
This commit is contained in:
parent
485538f90d
commit
da4549d77e
3 changed files with 0 additions and 0 deletions
35
src/main.js
35
src/main.js
|
@ -1,35 +0,0 @@
|
|||
(function () {
|
||||
"use strict";
|
||||
var words, inputElement, outputElement;
|
||||
|
||||
function translate(input) {
|
||||
var i, length, output, key, a = 'a'.charCodeAt(0), z = 'z'.charCodeAt(0);
|
||||
input = input.toLowerCase();
|
||||
output = "";
|
||||
length = input.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
key = input.charCodeAt(i) - a;
|
||||
if (key >= 0 && key <= 26) {
|
||||
if (i > 0) {
|
||||
output += " ";
|
||||
}
|
||||
output += words[key];
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function changeListener(event) {
|
||||
outputElement.innerHTML = translate(event.target.value);
|
||||
}
|
||||
|
||||
function init() {
|
||||
words = [ "Alfa", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliett", "Kilo", "Lima", "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor", "Whiskey", "X-ray", "Yankee", "Zulu" ];
|
||||
inputElement = document.getElementById("inputElement");
|
||||
outputElement = document.getElementById("outputElement");
|
||||
|
||||
inputElement.addEventListener("input", changeListener);
|
||||
}
|
||||
|
||||
init();
|
||||
}());
|
Loading…
Add table
Add a link
Reference in a new issue