-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
executable file
·106 lines (101 loc) · 2.32 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
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
101
102
103
104
105
106
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>jswtf</title>
<script type="text/javascript" src="jswtf.js"></script>
<style type="text/css">
#letters{
margin-bottom: 5px;
}
.letter{
display: inline-block;
width: 15px;
height: 15px;
padding: 10px;
margin: 5px;
background-color: grey;
}
.letter.over{
background-color: red;
}
</style>
</head>
<body>
<form>
<div id="letters"></div>
<textarea id="text" disabled="disabled"></textarea><br />
<input type="button" id="packB2" value="Pack Alert" /><!-- - <input type="button" id="packB1" value="Pack" /> --><br />
<textarea id="pack"></textarea><br />
<input type="button" id="test" value="Test" /> <input type="button" id="reset" value="Clean Up" />
</form>
<script type="text/javascript">
var text = document.getElementById('text'),
pack = document.getElementById('pack'),
/*packb1 = document.getElementById('packB1'),*/
packb2 = document.getElementById('packB2'),
test = document.getElementById('test'),
reset = document.getElementById('reset');
text.style.width = '100%';
text.style.height = '300px';
pack.style.width = '100%';
pack.style.height = '300px';
/*
packb1.onclick = function()
{
pack.value = JSWTF.Pack(text.value);
}*/
packb2.onclick = function()
{
pack.value = JSWTF.PackAlert(text.value);
}
test.onclick = function()
{
try
{
eval(pack.value);
}
catch(err)
{
alert('An error occured :-(');
}
}
reset.onclick = function()
{
text.value = '';
pack.value = '';
}
function clickALetter(e)
{
var c = (e.target.innerHTML == ' ') ? ' ' : e.target.innerHTML;
var trad = JSWTF.GetChar(c);
if(text.value == '')
text.value = trad;
else
text.value += '+'+trad;
}
// Yeah I know, this is bad
function mouseoverLetter(e)
{
e.target.className += ' over';
}
function mouseoutLetter(e)
{
e.target.className = 'letter';
}
var chars = JSWTF.GetCharsList();
var lettersDiv = document.getElementById('letters');
for(var i = 0; i < chars.length; i++)
{
var letter = document.createElement('span');
var c = (chars[i] == ' ') ? ' ' : chars[i];
letter.innerHTML = c;
letter.onclick = clickALetter;
letter.onmouseover = mouseoverLetter;
letter.onmouseout = mouseoutLetter;
letter.className = 'letter';
lettersDiv.appendChild(letter);
}
</script>
</body>
</html>