*** empty log message ***
[m17n/m17n-lib-js.git] / mim2.js
diff --git a/mim2.js b/mim2.js
index 7f78838..2bb2370 100644 (file)
--- a/mim2.js
+++ b/mim2.js
@@ -1149,33 +1149,33 @@ MIM.im_domain.DefType (MIM.State.prototype);
                                  + (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;
+       //Xex.Log ('parsing ' + name);
+       var parser = parsers[name];
+       if (parser)
+         parser.call (im, node);
+      }
+    //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)
   {
@@ -1688,11 +1688,9 @@ MIM.im_domain.DefType (MIM.State.prototype);
     }
   };
 
-  MIM.create_list = function (node) {
+  MIM.create_list = function (node)
+  {
     // Load the list of input methods.
-    MIM.A = node;
-    alert ('create-list called: node=' + MIM.A);
-    var node = node.firstElement;
     for (node = node.firstChild; node; node = node.nextSibling)
       if (node.nodeName == 'input-method')
        {
@@ -1726,14 +1724,17 @@ MIM.im_domain.DefType (MIM.State.prototype);
            }
        }
     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 ();
   }
 }) ();
 
@@ -2118,7 +2119,7 @@ MIM.keydown = function (event)
   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;
@@ -2372,6 +2373,7 @@ MIM.keypress = function (event)
     if (target.im)
       {
        MIM.current = target.im;
+       MIM.current.Load ();
        destroy ();
       }
     event.preventDefault ();