-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.html
108 lines (97 loc) · 4.43 KB
/
test.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
107
108
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript" src="src/categ_letters.js"></script>
<script type="text/javascript" src="src/categ_letters_numbers.js"></script>
<script type="text/javascript" src="src/categ_numbers.js"></script>
<script type="text/javascript" src="src/categ_puncts.js"></script>
<script type="text/javascript" src="src/categ_separators.js"></script>
<script type="text/javascript" src="src/categ_puncts_separators.js"></script>
<script type="text/javascript" src="src/categ_puncts_separators_controls.js"></script>
<script type="text/javascript" src="src/categ_controls.js"></script>
<script type="text/javascript" src="src/categ_maths.js"></script>
<script type="text/javascript" src="src/categ_currencies.js"></script>
<script type="text/javascript" src="src/normalizer_lowercase_nomark.js"></script>
<script type="text/javascript" src="src/normalizer_lowercase.js"></script>
<script type="text/javascript" src="src/normalizer_uppercase_nomark.js"></script>
<script type="text/javascript" src="src/normalizer_uppercase.js"></script>
<script type="text/javascript" src="src/unicode.js"></script>
<style TYPE="text/css">
div.floatbox {
float:left; width: 300px;
}
div.resultbox {
border: 1px solid black; margin:0.5em;
color: black; background-color: #EEEEEE;
overflow: hidden;
}
textarea.typebox {
float: left;
width: 300px; height: 300px; margin:1em;"
color: black; background-color: white;
}
</style>
</head>
<body>
<h1>Testing the Javascript Unicode support library</h1>
<div>
<textarea id="typehere" class="typebox"></textarea>
<div>Categories check on last character typed
<div>Char code:<span id="lastkey"></span></div>
<div>is_letter() <span id="is_letter"></span></div>
<div>is_number() <span id="is_number"></span></div>
<div>is_letter_number() <span id="is_letter_number"></span></div>
<div>is_punct() <span id="is_punct"></span></div>
<div>is_separator() <span id="is_separator"></span></div>
<div>is_punct_separator() <span id="is_punct_separator"></span></div>
<div>is_punct_separator_control() <span id="is_punct_separator_control"></span></div>
<div>is_control() <span id="is_control"></span></div>
<div>is_math() <span id="is_math"></span></div>
<div>is_currency() <span id="is_currency"></span></div>
</div>
</div>
<div style="clear:both">
<div class="floatbox">lowercase, decomposed, diacritical marks removed, using <tt>lowercase_nomark()</tt><div class="resultbox" id="result_lowercase_nomark" ></div></div>
<div class="floatbox">lowercase, decomposed, using <tt>lowercase()</tt><div class="resultbox" id="result_lowercase" ></div></div>
<div class="floatbox">uppercase, decomposed, diacritical marks removed, using <tt>uppercase_nomark()</tt><div class="resultbox" id="result_uppercase_nomark" ></div></div>
<div class="floatbox">uppercase, decomposed, using <tt>uppercase()</tt><div class="resultbox" id="result_uppercase" ></div></div>
</div>
<script type="text/javascript">
function displayRes($id, value) {
var str = "<div>length: " + value.length + "</div><hr/>";
str += "<div>" + value + "</div><hr/>";
for (var i=0, max=value.length; i<max; ++i) {
str += (i>0?" + ": "") + value.charCodeAt(i).toString(16);
}
$id.html(str);
}
function displayCat(c) {
var targets = ["is_letter_number", "is_letter", "is_number", "is_punct", "is_separator", "is_punct_separator", "is_punct_separator_control",
"is_control", "is_math", "is_currency"];
for (var i=0; i<targets.length; ++i) {
var res = net.kornr.unicode[targets[i]](c);
$("#"+targets[i]).html(res?"true":"false");
}
}
$(document).ready(function() {
$("#typehere").keypress(function(e) {
$("#lastkey").html("pressed: " + e.charCode);
displayCat(e.charCode);
});
$("#typehere").keyup(function() {
var value = $(this).val();
// console.log("value = " + value);
var lcnm = net.kornr.unicode.lowercase_nomark(value);
// console.log("lcnm = " + lcnm);
$("#result_lowercase_nomark").html(net.kornr.unicode.lowercase_nomark(value));
displayRes($("#result_lowercase_nomark"), net.kornr.unicode.lowercase_nomark(value));
displayRes($("#result_lowercase"), net.kornr.unicode.lowercase(value));;
displayRes($("#result_uppercase_nomark"), net.kornr.unicode.uppercase_nomark(value));
displayRes($("#result_uppercase"), net.kornr.unicode.uppercase(value));
});
});</script>
</body>
</html>