-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmorse.js
100 lines (100 loc) · 2.93 KB
/
morse.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
let Morse = {
getLetter : function(seq)
{
seq = seq.split("T");
let current = "";
for(let i = 0; i < seq.length; i++)
{
if(seq[i].length <= 0)
continue;
if(seq[i] == "i")
{
switch(current)
{
case "":
current = "E";
break;
case "E":
current = "I";
break;
case "I":
current = "S";
break;
case "S":
current = "H";
break;
case "U":
current = "F";
break;
case "R":
current = "L";
break;
case "W":
current = "P";
break;
case "T":
current = "N";
break;
case "N":
current = "D";
break;
case "D":
current = "B";
break;
case "K":
current = "C";
break;
case "M":
current = "G";
break;
case "G":
current = "Z";
break;
}
}
else
{
switch(current)
{
case "":
current = "T";
break;
case "T":
current = "M";
break;
case "M":
current = "O";
break;
case "G":
current = "Q";
break;
case "K":
current = "Y";
break;
case "D":
current = "X";
break;
case "N":
current = "K";
break;
case "W":
current = "J";
break;
case "A":
current = "W";
break;
case "S":
current = "V";
break;
case "I":
current = "U";
break;
case "E":
current = "A";
break;
}
}
}
return current;
}
};