Skip to content

Commit da36597

Browse files
author
zhourenjian@gmail.com
committed
Support debugging mode in other devices/browsers, like iPad/iPhone Safari browser.
Add a line like window["j2s.hotspot.host"] = "192.168.2.105";
1 parent 4640dc6 commit da36597

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

sources/net.sf.j2s.java.core/src/java/lang/ClassLoader.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ ClazzLoader.isOpera = (ClazzLoader.userAgent.indexOf ("opera") != -1);
210210
ClazzLoader.isIE = (ClazzLoader.userAgent.indexOf ("msie") != -1) && !ClazzLoader.isOpera;
211211
ClazzLoader.isGecko = (ClazzLoader.userAgent.indexOf ("gecko") != -1);
212212
ClazzLoader.isChrome = (ClazzLoader.userAgent.indexOf ("chrome") != -1);
213+
ClazzLoader.isSafari = (ClazzLoader.userAgent.indexOf ("safari") != -1);
214+
ClazzLoader.isMobileSafari = (ClazzLoader.isSafari && ClazzLoader.userAgent.indexOf ("mobile") != -1);
215+
ClazzLoader.randomlyReload = ClazzLoader.isSafari;
213216

214217
/*
215218
* Opera has different loading order which will result in performance degrade!
@@ -1179,7 +1182,7 @@ ClazzLoader.loadScript = function (file) {
11791182
// Create script DOM element
11801183
var script = document.createElement ("SCRIPT");
11811184
script.type = "text/javascript";
1182-
if (ClazzLoader.isChrome && ClazzLoader.reloadingClasses[file]) {
1185+
if (ClazzLoader.randomlyReload && ClazzLoader.reloadingClasses[file]) {
11831186
script.src = file + "?" + Math.floor (100000 * Math.random ());
11841187
} else {
11851188
script.src = file;
@@ -2823,7 +2826,7 @@ ClazzLoader.lastHotspotUpdated = new Date ().getTime ();
28232826
ClazzLoader.lastHotspotSessionID = 0;
28242827

28252828
/* Google Chrome need to load *.js using url + "?" + random number */
2826-
if (ClazzLoader.isChrome) {
2829+
if (ClazzLoader.randomlyReload) {
28272830
ClazzLoader.reloadingClasses = new Object ();
28282831
}
28292832

@@ -2874,15 +2877,15 @@ ClazzLoader.updateHotspot = function () {
28742877
for (var i = 0; i < toUpdateClasses.length; i++) {
28752878
if (needUpdateClasses[i]) {
28762879
var clzz = toUpdateClasses[i];
2877-
if (ClazzLoader.isChrome) {
2880+
if (ClazzLoader.randomlyReload) {
28782881
ClazzLoader.reloadingClasses[ClazzLoader.getClasspathFor (clzz)] = true;
28792882
}
28802883
ClazzLoader.loadClass (clzz, (function (clazz) {
28812884
return function () {
28822885
// succeeded!
28832886
Clazz.unloadedClasses[clazz] = null;
28842887
ClazzLoader.classReloaded (clazz);
2885-
if (ClazzLoader.isChrome) {
2888+
if (ClazzLoader.randomlyReload) {
28862889
ClazzLoader.reloadingClasses[ClazzLoader.getClasspathFor (clazz)] = false;
28872890
}
28882891
};
@@ -2978,7 +2981,11 @@ ClazzLoader.hotspotMonitoring = function () {
29782981
if (port == null) {
29792982
port = 1725;
29802983
}
2981-
var hotspotURL = "http://127.0.0.1:" + port;
2984+
var host = window["j2s.hotspot.host"];
2985+
if (host == null) {
2986+
host = "127.0.0.1";
2987+
}
2988+
var hotspotURL = "http://" + host + ":" + port;
29822989
if (ClazzLoader.lastHotspotSessionID == 0) {
29832990
hotspotURL += "/hotspot.js?" + Math.random ();
29842991
} else {

0 commit comments

Comments
 (0)