-
Notifications
You must be signed in to change notification settings - Fork 0
/
xltr.html
78 lines (68 loc) · 1.58 KB
/
xltr.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
76
77
78
<html>
<head>
<title>KLVN XL8R</title>
</head>
<body>
<form>
<p>
<textarea id="input" name="input" rows="20" cols="80">Raider Klan Input Text</textarea>
</p>
<p>
<button type="button">Translate</button>
</p>
<p>
<textarea id="output" name="output" rows="20" cols="80"></textarea>
</p>
</form>
</body>
<script>
function sendData(data) {
console.log(data);
const input = document.getElementById('input');
const output = document.getElementById('output');
console.log(input);
console.log(output);
const result = translate(input.value);
console.log(result);
output.value = result;
textToClipboard(result);
}
function textToClipboard (text) {
var dummy = document.createElement("textarea");
document.body.appendChild(dummy);
dummy.value = text;
dummy.select();
document.execCommand("copy");
document.body.removeChild(dummy);
}
const xforms = [
['a', '∀'],
['e', 'XX'],
['o', 'X'],
['u', 'X'],
['u', 'V'],
['s', 'Z'],
];
function translate(instr) {
if (instr === null || instr == '') {
return '';
}
var result = instr;
for (t in xforms) {
const parts = result.split(xforms[t][0]);
if (parts.length > 1) {
var outs = [];
for (p in parts) {
outs.push(translate(parts[p]));
}
result = outs.join(xforms[t][1]);
}
}
return result;
}
const btn = document.querySelector('button');
btn.addEventListener( 'click', function()
{ sendData( {test:'ok'} );
} )
</script>
</html>