UNPKG

jszhuyin

Version:

Smart Chinese Zhuyin Input Method in JavaScript.

61 lines (54 loc) 1.82 kB
<!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>