// Boolean flag to tell if MIM is running in debug mode or not.
debug: false,
// List of main input methods.
- imlist: null,
+ imlist: {},
// List of extra input methods;
imextra: {},
// Global input method data
}
};
-if (window.location.hostname == 'localhost')
- MIM.server = 'http://localhost/mim';
+//if (window.location.hostname == 'localhost')
+// MIM.server = 'http://localhost/mim';
(function () {
var keysyms = new Array ();
if (node.nodeName != 'tags')
return null;
- var lang = null, name = null, extra = null;
+ var lang = null, name = null, extra = null, im;
for (node = node.firstElement (); node; node = node.nextElement ())
{
if (node.nodeName == 'language')
if (! (im = MIM.imextra[lang][extra]))
return null;
}
- if (im.load_status != MIM.LoadStatus.Loaded
- && (im.load_status != MIM.LoadStatus.NotLoaded || ! im.Load ()))
- return null;
+ if (im.load_status != MIM.LoadStatus.Loaded)
+ {
+ if (im.load_status == MIM.LoadStatus.NotLoaded)
+ im.Load ();
+ if (im.load_status != MIM.LoadStatus.Loading)
+ return null;
+ }
return im;
}
parsers['description'] = function (node)
{
this.description = node.firstChild.nodeValue;
+ return true;
}
parsers['variable-list'] = function (node)
{
}
vname = Xex.Term.Parse (this.domain, node)
}
+ return true;
}
parsers['command-list'] = function (node)
{
+ return true;
}
parsers['macro-list'] = function (node)
{
{
var im = include (n);
if (! im)
- alert ('inclusion fail');
- else
- for (var macro in im.domain.functions)
- {
- var func = im.domain.functions[macro];
- if (func instanceof Xex.Macro)
- im.domain.CopyFunc (this.domain, macro);
- }
+ {
+ alert ('inclusion fail');
+ throw new Xex.ErrTerm (MIM.Error.ParseError, "inclusion fail: ");
+ }
+ if (im.load_status == MIM.LoadStatus.Loading)
+ return false; // force reloading
+ for (var macro in im.domain.functions)
+ {
+ var func = im.domain.functions[macro];
+ if (func instanceof Xex.Macro)
+ im.domain.CopyFunc (this.domain, macro);
+ }
n = n.previousSibling;
node.removeChild (n.nextSibling);
}
Xex.Term.Parse (this.domain, node.firstElement (), null);
+ return true;
}
parsers['title'] = function (node)
{
this.title = node.firstChild.nodeValue;
+ return true;
}
parsers['map-list'] = function (node)
{
if (! im)
{
alert ('inclusion fail');
- continue;
+ throw new Xex.ErrTerm (MIM.Error.ParseError, "inclusion fail: ");
}
+ else if (im.load_status == MIM.LoadStatus.Loading)
+ return false;
for (var mname in im.map_list)
this.map_list[mname] = im.map_list[mname];
}
this.map_list[map.name] = map;
}
}
+ return true;
}
parsers['state-list'] = function (node)
{
{
var im = include (node);
if (! im)
- alert ('inclusion fail');
+ {
+ alert ('inclusion fail');
+ throw new Xex.ErrTerm (MIM.Error.ParseError, "inclusion fail: ");
+ }
+ else if (im.load_status == MIM.LoadStatus.Loading)
+ return false;
for (var sname in im.state_list)
{
state = im.state_list[sname];
}
}
delete this.domain.map_list;
+ return true;
}
MIM.IM = function (lang, name, extra_id, file)
+ (this.name != 'nil'
? this.name : this.extra_id),
MIM.im_domain, null);
+ };
+
+ function load_im (node, im)
+ {
+ //alert ('Loading IM (' + im + ':' + im.lang + '-' + im.name + ')');
+ im.map_list = {};
+ im.initial_state = null;
+ im.state_list = {};
+ for (node = node.firstElement (); node; node = node.nextElement ())
+ {
+ var name = node.nodeName;
+ var parser = parsers[name];
+ if (parser && ! parser.call (im, node))
+ {
+ im.Load ();
+ return;
+ }
+ }
+ //alert ('initial state = ' + im.initial_state);
+ im.load_status = MIM.LoadStatus.Loaded;
}
- var proto = {
+ MIM.IM.prototype = {
Load: function ()
{
- var node = Xex.Load (MIM.server, this.file);
- if (! node)
- {
- this.load_status = MIM.LoadStatus.Error;
- return false;
- }
- this.map_list = {};
- this.initial_state = null;
- this.state_list = {};
- for (node = node.firstElement (); node; node = node.nextElement ())
- {
- var name = node.nodeName;
- var parser = parsers[name];
- if (parser)
- parser.call (this, node);
- }
- this.load_status = MIM.LoadStatus.Loaded;
- return true;
+ this.load_status = MIM.LoadStatus.Loading;
+ Xex.Load (MIM.server, this.file, load_im, this);
}
- }
-
- MIM.IM.prototype = proto;
+ };
MIM.IC = function (im, target)
{
}
};
- MIM.Load = function () {
- if (MIM.imlist)
- return;
- MIM.imlist = {};
+ MIM.create_list = function (node)
+ {
// Load the list of input methods.
- var node = Xex.Load (MIM.server, "imlist.xml");
for (node = node.firstChild; node; node = node.nextSibling)
if (node.nodeName == 'input-method')
{
}
}
if (MIM.imextra.t && MIM.imextra.t.global)
- MIM.im_global = MIM.imextra.t.global;
+ {
+ MIM.im_global = MIM.imextra.t.global;
+ MIM.im_global.Load ();
+ }
else
{
MIM.im_global = new MIM.IM ('t', 'nil', 'global', null);
MIM.im_global.load_status = MIM.LoadStatus.Error;
}
- node = undefined;
MIM.current = MIM.imlist['t']['latn-post'];
+ MIM.current.Load ();
}
}) ();
if (! (target.type == "text" || target.type == "textarea"))
return;
- MIM.Load ();
var ic = target.mim_ic;
if (! ic || ic.im != MIM.current)
{
target.mim_ic = null;
- Xex.Log ('creating IC');
+ Xex.Log ('creating IC for ' + MIM.current.lang + '-' + MIM.current.name);
ic = new MIM.IC (MIM.current, target);
if (ic.im.load_status != MIM.LoadStatus.Loaded)
return true;
if (target.im)
{
MIM.current = target.im;
+ MIM.current.Load ();
destroy ();
}
event.preventDefault ();
return;
if (! menu)
{
- MIM.Load ();
categorize_im ();
menu = create_ul ('visible');
menu.style.fontFamily = 'sans-serif';
MIM.add_event_listener (window, 'keydown', MIM.keydown);
MIM.add_event_listener (window, 'keypress', MIM.keypress);
MIM.add_event_listener (window, 'mousedown', create_menu);
+ Xex.Load (MIM.server, "imlist.xml", MIM.create_list);
};
}) ();