-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPokebell.js
More file actions
63 lines (58 loc) · 1.17 KB
/
Copy pathPokebell.js
File metadata and controls
63 lines (58 loc) · 1.17 KB
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
import { toHankaku } from "./kana.js";
const DTMF = {
"1": [ 697, 1209 ],
"2": [ 697, 1336 ],
"3": [ 697, 1477 ],
"A": [ 697, 1633 ],
"4": [ 770, 1209 ],
"5": [ 770, 1336 ],
"6": [ 770, 1477 ],
"B": [ 770, 1633 ],
"7": [ 852, 1209 ],
"8": [ 852, 1336 ],
"9": [ 852, 1477 ],
"C": [ 852, 1633 ],
"*": [ 941, 1209 ],
"0": [ 941, 1336 ],
"#": [ 941, 1477 ],
"D": [ 941, 1633 ]
}
const POKEBELL = [
"アイウエオABCDE",
"カキクケオFGHIJ",
"サシスセソKLMNO",
"タチツテトPQRST",
"ナニヌネノUVWXY",
"ハヒフヘホZ?!-/",
"マミムメモ¥& ☎ ",
"ヤ(ユ)ヨ*# ♥ ",
"ラリルレロ12345",
"ワヲン゙゚67890"
]
const toPokebell = function(c) {
for (let i = 0; i < POKEBELL.length; i++) {
const row = POKEBELL[i]
const n = row.indexOf(c)
if (n >= 0)
return "" + ((i + 1) % 10) + "" + ((n + 1) % 10)
}
return ""
}
// console.log(toHankaku("あいうえお"))
const getPokebellCode = function(s) {
if (toHankaku) {
s = toHankaku(s)
}
console.log(s)
const res = []
for (const c of s) {
res.push(toPokebell(c))
}
return res.join("")
}
class Pokebell {
static getCode(s) {
return getPokebellCode(s);
}
};
export { Pokebell };