// -* coding: utf-8; -*
-/* URL to scan JavaScript files defining MIM (M17N Input Method). */
-var MIM_url = "http://www.m17n.org/common/mim-js";
-
-/* Boolean flag to tell if MIM is active or not. */
-var MIM_enabled = true;
-
-var MIM_debug = false;
-
-var MIM_current_im;
-
-var MIM_list = new Array ();
-
-function M17N_im (url, lang, name)
+var MIM = function ()
{
- this.status = 0; /* 0: not-yet-loaded, 1:loading, 2:loaded, -1:error */
- this.url = url;
- this.lang = lang;
- this.name = name;
- this.keymap = false;
-
- function add_keystring (map, keystring, str)
+ var server = "http://www.m17n.org/common/mim-js",
+ /* Boolean flag to tell if MIM is active or not. */
+ var enabled = true;
+ /* Boolean flag to tell if MIM is running in debug mode or not. */
+ var debug = false;
+ var current_im = false;
+
+ function im (lang, name, filename)
{
- var i, c;
- var newmap;
- var intermediate_string = "";
+ this.status = 0; /* 0: not-yet-loaded, 1:loading, 2:loaded, -1:error */
+ this.url = server + "/" + filename;
+ this.lang = lang;
+ this.name = name;
+ this.keymap = false;
+
+ function add_keystring (map, keystring, str)
+ {
+ var i, c;
+ var newmap;
+ var intermediate_string = "";
- for (i = 0; i < keystring.length; i++)
+ for (i = 0; i < keystring.length; i++)
{
c = keystring.charAt (i);
if (c in map)
map['_target_text'] = intermediate_string;
}
}
- map['_target_text'] = str;
- }
+ map['_target_text'] = str;
+ }
- function lookup_keyseq (keyseq, limit)
- {
- var map = this.keymap;
+ function lookup_keyseq (keyseq, limit)
+ {
+ var map = this.keymap;
- if (limit > keyseq.length)
- limit = keyseq.length;
- for (var i = 0; i < limit; i++)
+ if (limit > keyseq.length)
+ limit = keyseq.length;
+ for (var i = 0; i < limit; i++)
{
var c = keyseq[i];
if (! (c in map))
return i;
map = map[c];
}
- return map;
- }
+ return map;
+ }
- function load_map (mapdef)
- {
- this.keymap = new Array ();
- for (var keystring in mapdef)
- add_keystring (this.keymap, keystring, mapdef[keystring]);
+ function load_map (mapdef)
+ {
+ this.keymap = new Array ();
+ for (var keystring in mapdef)
+ add_keystring (this.keymap, keystring, mapdef[keystring]);
+ }
+
+ this.load_mapdef = load_map;
+ this.lookup = lookup_keyseq;
}
- this.load_mapdef = load_map;
- this.lookup = lookup_keyseq;
-}
+ return { }
+} ();
function MIM_register (url, lang, name)
{