1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
4 <meta http-equiv="content-type" content="text/html; charset=utf-8">
5 <style type="text/css">
7 td { font-family: 'monospace'; font-size: 12pt}
8 textarea { font-size: 20pt; width: 100mm; }
11 <title>M17N Input Method by JavaScript</title>
12 <script src="xex2.js"></script>
13 <script src="mim2.js"></script>
14 <script type="text/javascript">
15 MIM.debug_print = function (event, ic)
19 if (! MIM.debug_nodes['status0'])
24 MIM.debug_nodes = new Array ();
25 MIM.debug_nodes['status0'] = document.getElementById ('status0');
26 if (! MIM.debug_nodes['status0'])
28 MIM.debug_nodes['status1'] = document.getElementById ('status1');
29 MIM.debug_nodes['keydown'] = document.getElementById ('keydown');
30 MIM.debug_nodes['keypress'] = document.getElementById ('keypress');
31 MIM.debug_nodes['keymap0'] = document.getElementById ('keymap0');
32 MIM.debug_nodes['keymap1'] = document.getElementById ('keymap1');
33 MIM.debug_nodes['preedit0'] = document.getElementById ('preedit0');
34 MIM.debug_nodes['preedit1'] = document.getElementById ('preedit1');
35 MIM.debug_nodes['range0'] = document.getElementById ('range0');
36 MIM.debug_nodes['range1'] = document.getElementById ('range1');
38 var target = event.target;
39 var code = event.keyCode;
40 var ch = event.type == 'keypress' ? event.charCode : 0;
41 var key = MIM.decode_key_event (event);
44 if (event.type == 'keypress' || event.type == 'keydown')
45 MIM.debug_nodes[event.type].innerHTML = "" + code + "/" + ch + ":" + key + '/' + event.keyIdentifier;
46 index = (event.type == 'keydown' ? '0' : '1');
48 MIM.debug_nodes['status' + index].innerHTML = ic.im.load_status;
50 MIM.debug_nodes['status' + index].innerHTML = 'no IM';
51 MIM.debug_nodes['keymap' + index].innerHTML = ic.state.name;
52 MIM.debug_nodes['preedit' + index].innerHTML = ic.preedit;
53 MIM.debug_nodes['range' + index].innerHTML
54 = ic.range[0]+'-'+ic.range[1]+'-'+ic.cursor_pos;
57 MIM.debug_nodes.keypress.innerHTML = '';
58 MIM.debug_nodes.status1.innerHTML = '';
59 MIM.debug_nodes.keymap1.innerHTML = '';
60 MIM.debug_nodes.preedit1.innerHTML = ''
61 MIM.debug_nodes.range1.innerHTML = ''
64 function toggle_debug (event)
67 event.preventDefault ();
73 <body onload="MIM.init ()">
74 <h4>m17n-lib input method in Javascript (tested only on Chrome)</h4>
75 The default input method is latn-post.
76 Click an input area by Control-Mouse-1 to select any other input method.<br>
78 <tr><th>textarea</th><td><textarea id="TEXTAREA" name="TEXTAREA"></textarea></td></tr>
79 <tr><th>text</th><td><form><input type="text" id="TEXT"></form></td></tr></table>
80 <div style="font-weight: bold;">debug Info<pre id="im"></pre></div>
82 <tr><th>key</th><th>status</th><th>keycode</th><th>keymap</th><th>preedit</th><th>range</th></tr>
83 <tr><th>down</th><td id="status0"></td><td id="keydown">0</td><td id="keymap0"></td><td id="preedit0"></td><td id="range0"></td></tr>
84 <tr><th>press</th><td id="status1"></td><td id="keypress">0</td><td id="keymap1"></td><td id="preedit1"></td><td id="range1"></td></tr>
89 <a href="javascript:(function(){var%20s=document.createElement(%22script%22);s.src=%22http://www.m17n.org/common/mim-js/xex.js%22;document.body.appendChild(s);s=document.createElement(%22script%22);s.src=%22http://www.m17n.org/common/mim-js/mim.js%22;document.body.appendChild(s);setTimeout(function(){MIM.init();},2000);})();">MIM-JS</a>
90 to the bookmark. Then, you can activate the MIM input method on any page
91 when you access the bookmarked link.<br>
93 <input type="button" value="Click here to toggle logging!"
94 onmousedown="toggle_debug ()">