-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
50 lines (37 loc) · 1.16 KB
/
demo.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CantoJpMin Demo</title>
</head>
<!-- Load the 2 CantoJpMin files -->
<script src="scripts/cantojpmin_data.js"></script>
<script src="scripts/cantojpmin_functions.js"></script>
<!-- . -->
<body>
<h1>CantoJpMin Demo</h1>
<p>Enter Traditional Chinese characters:</p>
<textarea id="input-field" rows="10" cols="40">食咗飯未呀?🍚</textarea>
<p>Prints Jyutping:</p>
<p id="jyutping-display">…</p>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>
$(document).ready(function() {
// Run conversion once when document has loaded
convertInputFieldToJyutping();
// Run conversion every time the text is changed
$('#input-field').on('input', function() {
convertInputFieldToJyutping();
});
});
function convertInputFieldToJyutping() {
var txt = $('#input-field').val();
// print the Jyutping options
console.log(CantoJpMin.toJyutpingArray(txt));
// Convert to Jyutping
var jyutping = CantoJpMin.toJyutping(txt);
$('#jyutping-display').html(jyutping);
}
</script>
</html>