JAL-3263 variable name now 秘html5Applet
[jalview.git] / src / jalview / util / Platform.java
index 523f816..0c962f7 100644 (file)
@@ -32,6 +32,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Properties;
 
@@ -331,7 +332,9 @@ public class Platform
 
   public static byte[] getFileBytes(File f)
   {
-    return /** @j2sNative f && f._bytes || */
+    // TODO temporary doubling of 秘bytes and _bytes;
+    // just remove _bytes when new transpiler has been installed
+    return /** @j2sNative f && (f.秘bytes || f._bytes) || */
     null;
   }
 
@@ -369,8 +372,10 @@ public class Platform
     }
     @SuppressWarnings("unused")
     byte[] bytes = getFileAsBytes(urlstring);
+    // TODO temporary doubling of 秘bytes and _bytes;
+    // just remove _bytes when new transpiler has been installed
     /**
-     * @j2sNative f._bytes = bytes;
+     * @j2sNative f.秘bytes = f._bytes = bytes;
      */
     return true;
   }
@@ -405,10 +410,11 @@ public class Platform
    * @param url
    * @return true if window has been opened
    */
-  public static boolean openURL(String url)
+  public static boolean openURL(String url) throws IOException
   {
     if (!isJS())
     {
+      BrowserLauncher.openURL(url);
       return false;
     }
     /**
@@ -425,7 +431,7 @@ public class Platform
     @SuppressWarnings("unused")
     ThreadGroup g = Thread.currentThread().getThreadGroup();
     /**
-     * @j2sNative return g.html5Applet._uniqueId;
+     * @j2sNative return g.秘html5Applet._uniqueId;
      *
      */
     return null;
@@ -451,13 +457,13 @@ public class Platform
     String id = getUniqueAppletID();
     String key = "", value = "";
     /**
-     * @j2sNative var info = g.html5Applet.__Info || {}; for (var key in info) {
-     *            if (key.indexOf(prefix) == 0) { value = "" + info[key];
+     * @j2sNative var info = g.秘html5Applet.__Info || {}; for (var key in info)
+     *            { if (key.indexOf(prefix) == 0) { value = "" + info[key];
      */
 
     System.out.println(
             "Platform id=" + id + " reading Info." + key + " = " + value);
-    p.put(id + "_" + key, value);
+    p.put(key, value);
 
     /**
      * @j2sNative
@@ -611,4 +617,34 @@ public class Platform
 
   }
 
+  public static URL getDocumentBase()
+  {
+    try
+    {
+      return (isJS() ? new URL(/**
+                                * @j2sNative J2S.thisApplet._applet.appletViewer.appletDocumentBase
+                                *            ||
+                                */
+              "") : null);
+    } catch (MalformedURLException e)
+    {
+      return null;
+    }
+  }
+
+  public static URL getCodeBase()
+  {
+    try
+    {
+      return (isJS() ? new URL(/**
+                                * @j2sNative J2S.thisApplet._applet.appletViewer.appletCodeBase
+                                *            ||
+                                */
+              "") : null);
+    } catch (MalformedURLException e)
+    {
+      return null;
+    }
+  }
+
 }