|
1 | 1 | // j2sApplet.js BH = Bob Hanson hansonr@stolaf.edu |
2 | 2 |
|
| 3 | +// BH 2025.08.16 allow loading file:/// from current directory |
3 | 4 | // BH 2025.04.20 adds Info.coreAssets:"coreAssets.zip" |
4 | 5 | // BH 2025.04.18 enables Info.readyFunction for headless apps |
5 | 6 | // BH 2025.04.17 adds option for explicit directory for core files different from j2sPath/core |
@@ -189,6 +190,7 @@ window.J2S = J2S = (function() { |
189 | 190 | // null here means no conversion necessary |
190 | 191 | "INTERNET.TEST" : "https://pubchem.ncbi.nlm.nih.gov", |
191 | 192 | "chemapps.stolaf.edu" : null, |
| 193 | + "zakodium.com":null, |
192 | 194 | "cactus.nci.nih.gov" : null, |
193 | 195 | ".x3dna.org" : null, |
194 | 196 | "rruff.geo.arizona.edu" : null, |
@@ -922,17 +924,25 @@ if (database == "_" && J2S._serverUrl.indexOf("//your.server.here/") >= 0) { |
922 | 924 | // swingjs.api.J2SInterface |
923 | 925 | // use host-server PHP relay if not from this host |
924 | 926 |
|
925 | | - if (fileName.indexOf("/") == 0) |
| 927 | + if (fileName.indexOf("/") == 0) { |
926 | 928 | fileName = "." + fileName; |
927 | | - else if (fileName.indexOf("https://./") == 0) |
| 929 | + } else if (fileName.indexOf("https://./") == 0) { |
928 | 930 | fileName = fileName.substring(10); |
929 | | - else if (fileName.indexOf("http://./") == 0) |
| 931 | + } else if (fileName.indexOf("http://./") == 0) { |
930 | 932 | fileName = fileName.substring(9); |
931 | | - else if (fileName.indexOf("file:/") >= 0 |
932 | | - && Clazz.loadClass("swingjs.JSUtil") != null |
933 | | - && fileName.indexOf(swingjs.JSUtil.getAppletDocumentPath$()) != 0 |
934 | | - && fileName.indexOf(swingjs.JSUtil.getAppletCodePath$()) != 0) |
935 | | - fileName = "./" + fileName.substring(5); |
| 933 | + } else if (fileName.indexOf("file:/") >= 0) { |
| 934 | + var pt = fileName.lastIndexOf("/"); |
| 935 | + if (fileName.indexOf("/core_") == pt && fileName.endsWith(".js") |
| 936 | + || document && (pt = document.location.href.lastIndexOf("/") + 1) > 0 |
| 937 | + && fileName.indexOf(document.location.href.substring(0, pt) == 0)) { |
| 938 | + // allow core_*.js from anywhere, or other files within the local document path |
| 939 | + } else if (Clazz.loadClass("swingjs.JSUtil") != null |
| 940 | + && fileName.indexOf(swingjs.JSUtil.getAppletDocumentPath$()) != 0 |
| 941 | + && fileName.indexOf(swingjs.JSUtil.getAppletCodePath$()) != 0) { |
| 942 | + // applet only, not application |
| 943 | + fileName = "./" + fileName.substring(5); |
| 944 | + } |
| 945 | + } |
936 | 946 | isBinary = (isBinary || J2S.isBinaryUrl(fileName)); |
937 | 947 | var isPDB = !noProxy && (fileName.indexOf("pdb.gz") >= 0 && fileName |
938 | 948 | .indexOf("//www.rcsb.org/pdb/files/") >= 0); |
@@ -977,6 +987,10 @@ if (database == "_" && J2S._serverUrl.indexOf("//your.server.here/") >= 0) { |
977 | 987 | info.type = "POST"; |
978 | 988 | info.url = fileName.split("?POST?")[0] |
979 | 989 | info.data = fileName.split("?POST?")[1] |
| 990 | + if (info.data.startsWith('{"')) { |
| 991 | + info.contentType = "application/json"; |
| 992 | + info.data = info.data.replaceAll("\n", "\\\\n"); |
| 993 | + } |
980 | 994 | } else { |
981 | 995 | !info.type && (info.type = "GET"); |
982 | 996 | info.url = fileName; |
|
0 commit comments