@@ -10686,6 +10686,7 @@ return jQuery;
10686
10686
})(jQuery,document,"click mousemove mouseup touchmove touchend", "outjsmol");
10687
10687
// j2sApplet.js BH = Bob Hanson hansonr@stolaf.edu
10688
10688
10689
+ // BH 2025.04.17 adds option for explicit directory for core files different from j2sPath/core
10689
10690
// BH 2024.11.09 makes equivalent J2S._debugCore and J2S._nozcore, as well as J2S._debugCode and J2S._nocore
10690
10691
// BH 2024.10.03 adds two-finger tap as "click"; reinstates touch gestures lost when we went to pointerup 2023.11.01
10691
10692
// BH 2023.12.14 fixes resizing into application (making it smaller)
@@ -11964,8 +11965,6 @@ if (database == "_" && J2S._serverUrl.indexOf("//your.server.here/") >= 0) {
11964
11965
}
11965
11966
}
11966
11967
11967
- J2S.getClassList = function(){J2S._saveFile('_j2sclasslist.txt', Clazz.ClassFilesLoaded.sort().join('\n'))}
11968
-
11969
11968
// J2S._localFileSaveFunction -- // do something local here; Maybe try the
11970
11969
// FileSave interface? return true if successful
11971
11970
@@ -13275,26 +13274,39 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
13275
13274
type = null;
13276
13275
}
13277
13276
13277
+ var thisPath, isFullName;
13278
13278
if (type) {
13279
- type = type.toLowerCase().split(".")[0]; // package name only
13279
+ var key = type.toLowerCase().substring(type.lastIndexOf("/") + 1);
13280
+ key = key.toLowerCase().split(".")[0]; // package name only
13280
13281
13281
13282
// return if type is already part of the set.
13282
- if (__coreSet.join("").indexOf(type ) >= 0)
13283
+ if (__coreSet.join("").indexOf(key ) >= 0)
13283
13284
return;
13284
13285
13286
+ __coreSet.push(key);
13287
+ __coreSet.sort();
13288
+
13285
13289
// create a concatenated lower-case name for a core file that
13286
13290
// includes
13287
13291
// all Java applets on the page
13292
+ // only if this is not a full name
13288
13293
13289
- __coreSet.push(type);
13290
- __coreSet.sort();
13291
- J2S._coreFiles = [ path + "/core/core" + __coreSet.join("")
13292
- + ".z.js" ];
13294
+ // 2025.04.17 adds option to give full (local) path to core file
13295
+ isFullName = (type.indexOf("/") >= 0);
13296
+ if (isFullName){
13297
+ // bypass core/package.js
13298
+ J2S.Globals["core.registered"] = true;
13299
+ }
13300
+ thisPath = (isFullName ? type : path + "/core/core" + __coreSet.join("") + ".z.js");
13301
+ J2S._coreFiles = [ thisPath ];
13293
13302
}
13294
13303
if (more && (Array.isArray(more) || (more = more.split(" "))))
13295
13304
for (var i = 0; i < more.length; i++)
13296
- if (more[i] && __coreMore.join("").indexOf(more[i]) < 0)
13297
- __coreMore.push(path + "/core/core" + more[i] + ".z.js")
13305
+ if (more[i] && __coreMore.join("").indexOf(more[i]) < 0) {
13306
+ isFullName = (more[i].indexOf("/") >= 0);
13307
+ thisPath = (isFullName ? type : path + "/core/core" + more[i] + ".z.js");
13308
+ __coreMore.push(thisPath);
13309
+ }
13298
13310
for (var i = 0; i < __coreMore.length; i++)
13299
13311
J2S._coreFiles.push(__coreMore[i]);
13300
13312
}
@@ -13492,15 +13504,6 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
13492
13504
return c;
13493
13505
}
13494
13506
13495
- var __j2sDebugCode = function() {
13496
- if (!document.getElementById("j2sprofile")) {
13497
- $('body').append(`<div id=j2sprofile><a href='javascript:J2S.getProfile()'>start/stop profiling</a> <a href="javascript:J2S.getClassList()">get _j2sClassList.txt</a></div>`);
13498
- }
13499
- if (!document.getElementById("sysoutdiv")) {
13500
- $('body').append(`<div spellcheck="false" id="sysoutdiv" contentEditable="true" style="border:1px solid green;width:800;height:300;overflow:auto">This is System.out</div>`);
13501
- }
13502
- }
13503
-
13504
13507
proto._setupJS = function() {
13505
13508
J2S.setGlobal("j2s.lib", {
13506
13509
base : this._j2sPath + "/",
@@ -13510,15 +13513,10 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
13510
13513
});
13511
13514
J2S.setGlobal("j2s.tmpdir", "/TEMP/");
13512
13515
var isFirst = (__execStack.length == 0);
13513
- if (isFirst)
13516
+ if (isFirst)
13514
13517
J2S._addExec([ this, __loadClazz, null, "loadClazz" ]);
13515
13518
this._addCoreFiles();
13516
13519
J2S._addExec([ this, this.__startAppletJS, null, "start applet" ])
13517
-
13518
- if (J2S._debugCode) {
13519
- J2S._addExec([ this, __j2sDebugCode, null, "j2sdebugcode" ])
13520
- }
13521
-
13522
13520
this._isSigned = true; // access all files via URL hook
13523
13521
this._ready = false;
13524
13522
this._applet = null;
@@ -14159,6 +14157,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
14159
14157
14160
14158
// Google closure compiler cannot handle Clazz.new or Clazz.super
14161
14159
14160
+ // BH 2025.04.17 adds option for explicit directory for core files different from j2sPath/core
14162
14161
// BH 2025.03.12 adds support for writable byte[] parameters in WASM
14163
14162
// BH 2025.03.06 adds support for JNA+WASM, automated loading of Java native classes if WASM is available
14164
14163
// BH 2025.02.22 add hashCode$() for Java Integer.TYPE and related types
@@ -14874,6 +14873,8 @@ Clazz.new_ = function(c, args, cl) {
14874
14873
return obj;
14875
14874
}
14876
14875
14876
+ Clazz._Pointer = null;
14877
+
14877
14878
Clazz._loadWasm = function(cls, lib){
14878
14879
if (cls.wasmLoaded)
14879
14880
return;
@@ -15010,6 +15011,9 @@ Clazz._loadWasm = function(cls, lib){
15010
15011
var retType = "number";
15011
15012
switch (jsm.nativeReturn) {
15012
15013
case "com.sun.jna.Pointer":
15014
+ if (!Clazz._Pointer) {
15015
+ Clazz._Pointer = Clazz.load("com.sun.jna.Pointer");
15016
+ }
15013
15017
fret = retPtr;
15014
15018
break;
15015
15019
case "[B": // It is assumed these are strings
@@ -15055,7 +15059,6 @@ Clazz._loadWasm = function(cls, lib){
15055
15059
cls.wasmInitialized = true;
15056
15060
J2S.wasm[libName].$ready = true;
15057
15061
}
15058
- // may have been preloaded by other JavaScript
15059
15062
var module = J2S[libName + "_module"]
15060
15063
if (module)
15061
15064
f(module);
@@ -16852,9 +16855,10 @@ _Loader.loadPackageClasspath = function (pkg, base, isIndex, fSuccess, mode, pt)
16852
16855
// the package idea has been deprecated
16853
16856
// the only package is core/package.js
16854
16857
if (pkg == "java")
16855
- pkg = "core" // JSmol -- moves java/package.js to core/package.js
16858
+ pkg = (J2S.Globals[ "core.registered"] ? null : "core") // JSmol -- moves java/package.js to core/package.js
16856
16859
// not really asynchronous
16857
- _Loader.loadClass(pkg + ".package", null, true, true, 1);
16860
+ if (pkg)
16861
+ _Loader.loadClass(pkg + ".package", null, true, true, 1);
16858
16862
}
16859
16863
fSuccess && fSuccess();
16860
16864
};
0 commit comments