Revision: 20408
          http://sourceforge.net/p/jmol/code/20408
Author:   hansonr
Date:     2015-03-28 13:39:21 +0000 (Sat, 28 Mar 2015)
Log Message:
-----------
JSmol JavaScript library update

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/adapter/readers/xml/XmlReader.java

Modified: trunk/Jmol/src/org/jmol/adapter/readers/xml/XmlReader.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/xml/XmlReader.java  2015-03-28 
01:40:21 UTC (rev 20407)
+++ trunk/Jmol/src/org/jmol/adapter/readers/xml/XmlReader.java  2015-03-28 
13:39:21 UTC (rev 20408)
@@ -192,16 +192,17 @@
       }
       if (o instanceof BufferedInputStream)
         o = Rdr.StreamToUTF8String(Rdr.getBIS(data));
+      // untested in j2s
       /**
        * 
        * @j2sNative
        * 
        *            this.domObj[0] =
-       *            parent.vwr.html5Applet._createDomNode("xmlReader",o);
+       *            this.createDomNodeJS("xmlReader",o);
        *            this.walkDOMTree();
-       *            parent.vwr.html5Applet._createDomNode("xmlReader",null);
+       *            this.createDomNodeJS("xmlReader",null);
        * 
-       */
+       */ 
       {
         walkDOMTree();
       }
@@ -211,6 +212,59 @@
       saxHandler.parseXML(this, saxReader, reader);
     }
   }
+  
+  @SuppressWarnings("unused")
+  private void createDomNodeJS(String id, Object data) {
+    // JavaScript only; untested
+    // no doubt there is a more efficient way to do this.
+    // Firefox, at least, does not recognize "/>" in HTML blocks
+    // that are added this way.
+    /**
+     * 
+     * @j2sNative
+     * 
+    proto._createDomNode = function(id, data) {
+      id = this._id + "_" + id;
+      var d = document.getElementById(id);
+      if (d)
+        document.body.removeChild(d);
+      if (!data)
+        return;
+      if (data.indexOf("<?") == 0)
+        data = data.substring(data.indexOf("<", 1));
+      if (data.indexOf("/>") >= 0) {
+        var D = data.split("/>");
+        for (var i = D.length - 1; --i >= 0;) {
+          var s = D[i];
+          var pt = s.lastIndexOf("<") + 1;
+          var pt2 = pt;
+          var len = s.length;
+          var name = "";
+          while (++pt2 < len) {
+            if (" \t\n\r".indexOf(s.charAt(pt2))>= 0) {
+              var name = s.substring(pt, pt2);
+              D[i] = s + "></"+name+">";
+              break;
+            }     
+          }
+        }
+        data = D.join('');
+      }
+      d = document.createElement("_xml");
+      d.id = id;
+      d.innerHTML = data;
+      d.style.display = "none";
+      document.body.appendChild(d);
+      return d;
+    }   
+     * 
+     */
+    {
+      // only called by j2s
+    }
+      
+  }
+  
   @Override
   public void applySymmetryAndSetTrajectory() {
     try {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to