-
Notifications
You must be signed in to change notification settings - Fork 18
/
console.html
60 lines (54 loc) · 1.78 KB
/
console.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
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>JSZhuyin playground</title>
<!-- script -->
<script src="./lib/bopomofo_encoder.js"></script>
<script src="./lib/jszhuyin_data_pack.js"></script>
<script src="./lib/storage.js"></script>
<script src="./lib/data_loader.js"></script>
<script src="./lib/jszhuyin.js"></script>
<script src="./lib/web.js"></script>
<!-- in case the user want to play with client and webIME -->
<script src="./lib/client.js"></script>
<script src="./lib/web.js"></script>
<script>
window.jszhuyin = new JSZhuyin();
(['loadend',
'load',
'error',
'unload',
'compositionupdate',
'compositionend',
'candidateschange',
'actionhandled']).forEach(function attachCallback(type) {
window.jszhuyin['on' + type] =
console.log.bind(console, type);
});
window.jszhuyin.load();
window.storage = window.jszhuyin.storage;
// Attach some helper methods to native objects.
String.prototype.toEncodedSounds = function() {
return BopomofoEncoder.encode(this);
};
String.prototype.toDecodedSounds = function() {
return BopomofoEncoder.dncode(this);
};
String.prototype.toBopomofo = function() {
return this.split('')
.map(function(chr) {
return JSZhuyinLayoutMapper.getSymbolFromDOM3Code(
D3EKeyboardEventHelper.getCodePropFromEvent({
charCode: chr.charCodeAt(0) }));
})
.join('');
};
Array.prototype.toConsoleTable = function() { console.table(this); };
</script>
</head>
<body>
<p>Please turn on the browser built-in console to work with <code>jszhuyin</code> intance.</p>
</body>
</html>