Skip to content

Commit ec4b234

Browse files
author
zhourenjian
committed
No blocking on query of JavaScript Hotspot, so no "loading" indicator for Firefox, and Opera will be much happier.
1 parent 80c124c commit ec4b234

File tree

1 file changed

+15
-89
lines changed

1 file changed

+15
-89
lines changed

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

Lines changed: 15 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,7 @@ ClazzLoader.load = function (musts, clazz, optionals, declaration) {
19321932
if (declaration != null) {
19331933
node.status = ClazzNode.STATUS_CONTENT_LOADED;
19341934
}
1935-
1935+
19361936
var isOptionalsOK = true;
19371937
if (optionals != null && optionals.length != 0) {
19381938
ClazzLoader.unwrapArray (optionals);
@@ -2577,9 +2577,9 @@ ClazzLoader.updateHotspot = function () {
25772577
Clazz.assureInnerClass = ClazzLoader.assureInnerClass;
25782578
}
25792579
var args = arguments[0];
2580-
//if (arguments.length != 1 || arguments[0] == null) {
2581-
// args = arguments;
2582-
//}
2580+
if (arguments.length != 1 || arguments[0] == null) {
2581+
args = arguments;
2582+
}
25832583
var length = (args.length - 1) / 3;
25842584
var lastID = 0;
25852585
/*-# lastUpdated -> lUd #-*/
@@ -2659,43 +2659,17 @@ ClazzLoader.loadHotspotScript = function (hotspotURL, iframeID) {
26592659
if (typeof (script.onreadystatechange) == "undefined") { // W3C
26602660
script.onload = script.onerror = function () {
26612661
try {
2662-
//if (iframeID != null) {
2663-
if (window.parent == null || window.parent["ClassLoader"] == null) return;
2664-
window.parent.ClassLoader.lastHotspotScriptLoaded = true;
2665-
var iframe = window.parent.document.getElementById (iframeID);
2666-
if (iframe != null) {
2667-
iframe.parentNode.removeChild (iframe);
2668-
if (window.parent.ClassLoader.hotspotMonitoringTimeout != null) {
2669-
window.parent.clearTimeout (window.parent.ClassLoader.hotspotMonitoringTimeout);
2670-
window.parent.ClassLoader.hotspotMonitoringTimeout = null;
2671-
}
2672-
}
2673-
// return;
2674-
//}
2675-
//ClazzLoader.lastHotspotScriptLoaded = true;
2676-
//ClazzLoader.removeHotspotScriptNode (this);
2662+
ClazzLoader.lastHotspotScriptLoaded = true;
2663+
ClazzLoader.removeHotspotScriptNode (this);
26772664
} catch (e) {}; // refreshing browser may cause exceptions
26782665
};
26792666
} else {
26802667
script.onreadystatechange = function () {
26812668
var state = "" + this.readyState;
26822669
if (state == "loaded" || state == "complete") {
26832670
try {
2684-
//if (iframeID != null) {
2685-
if (window.parent == null || window.parent["ClassLoader"] == null) return;
2686-
window.parent.ClassLoader.lastHotspotScriptLoaded = true;
2687-
var iframe = window.parent.document.getElementById (iframeID);
2688-
if (iframe != null) {
2689-
iframe.parentNode.removeChild (iframe);
2690-
if (window.parent.ClassLoader.hotspotMonitoringTimeout != null) {
2691-
window.parent.clearTimeout (window.parent.ClassLoader.hotspotMonitoringTimeout);
2692-
window.parent.ClassLoader.hotspotMonitoringTimeout = null;
2693-
}
2694-
}
2695-
// return;
2696-
//}
2697-
//ClazzLoader.lastHotspotScriptLoaded = true;
2698-
//ClazzLoader.removeHotspotScriptNode (this);
2671+
ClazzLoader.lastHotspotScriptLoaded = true;
2672+
ClazzLoader.removeHotspotScriptNode (this);
26992673
} catch (e) {}; // refreshing browser may cause exceptions
27002674
}
27012675
};
@@ -2704,57 +2678,6 @@ ClazzLoader.loadHotspotScript = function (hotspotURL, iframeID) {
27042678
head.appendChild (script);
27052679
};
27062680

2707-
/* private */
2708-
ClazzLoader.iframeDocumentWrite = function (handle, html) {
2709-
if (handle.contentWindow != null) {
2710-
handle.contentWindow.location = "about:blank";
2711-
} else { // Opera
2712-
handle.src = "about:blank";
2713-
}
2714-
try {
2715-
handle.contentWindow.document.write (html);
2716-
handle.contentWindow.document.close ();
2717-
} catch (e) {
2718-
window.setTimeout ((function () {
2719-
return function () {
2720-
handle.contentWindow.document.write (html);
2721-
handle.contentWindow.document.close ();
2722-
};
2723-
}) (), 25);
2724-
}
2725-
};
2726-
2727-
/* private */
2728-
ClazzLoader.loadHostspotIFrame = function (hotspotURL) {
2729-
var iframe = document.createElement ("IFRAME");
2730-
iframe.style.display = "none";
2731-
var iframeID = null;
2732-
do {
2733-
iframeID = "hotspot-script-" + Math.round (10000000 * Math.random ());
2734-
} while (document.getElementById (iframeID) != null);
2735-
iframe.id = iframeID;
2736-
document.body.appendChild (iframe);
2737-
var html = "<html><head><title></title>";
2738-
html += "<script type=\"text/javascript\">\r\n";
2739-
html += "var Clazz" + "Loader = new Object ();\r\n";
2740-
html += "Clazz" + "Loader.updateHotspot = function () {\r\n";
2741-
html += " var args = new Array ();\r\n";
2742-
html += " for (var i = 0; i < arguments.length; i++) {\r\n";
2743-
html += " args[i] = arguments[i];\r\n";
2744-
html += " }\r\n";
2745-
html += " with (window.parent) {\r\n";
2746-
html += " ClassLoader.updateHotspot (args);\r\n";
2747-
html += " };\r\n";
2748-
html += "};\r\n";
2749-
html += "</scr" + "ipt></head><body><script type=\"text/javascript\">\r\n";
2750-
html += "(" + ClazzLoader.loadHotspotScript + ") (";
2751-
html += "\"" + hotspotURL.replace (/"/g, "\\\"") + "\", \"" + iframeID + "\"";
2752-
html += ");\r\n";
2753-
html += "</scr" + "ipt></body></html>";
2754-
ClazzLoader.iframeDocumentWrite (iframe, html);
2755-
return iframeID;
2756-
};
2757-
27582681
/* protected */
27592682
/*-# hotspotMonitoring -> htMr #-*/
27602683
ClazzLoader.hotspotMonitoring = function () {
@@ -2775,8 +2698,7 @@ ClazzLoader.hotspotMonitoring = function () {
27752698
ClazzLoader.lastHotspotJSFailed = true;
27762699
ClazzLoader.lastHotspotScriptLoaded = false;
27772700

2778-
//ClazzLoader.loadHotspotScript (hotspotURL);
2779-
ClazzLoader.loadHostspotIFrame (hotspotURL);
2701+
ClazzLoader.loadHotspotScript (hotspotURL);
27802702

27812703
if (ClazzLoader.hotspotJSTimeout != null) {
27822704
window.clearTimeout (ClazzLoader.hotspotJSTimeout);
@@ -2785,10 +2707,14 @@ ClazzLoader.hotspotMonitoring = function () {
27852707
ClazzLoader.hotspotJSTimeout = window.setTimeout (function () {
27862708
ClazzLoader.lastHotspotScriptLoaded = true; // timeout
27872709
ClazzLoader.lastHotspotJSFailed = false; // timeout
2788-
}, 7500); // 7.5 seconds to time out
2710+
}, 2000);
2711+
/*
2712+
* 2 seconds to time out. For local server running inside Eclipse
2713+
* 2 seconds is already a very long time!
2714+
*/
27892715
}
27902716

2791-
window.setTimeout (ClazzLoader.hotspotMonitoring, 250);
2717+
window.setTimeout (ClazzLoader.hotspotMonitoring, 2500);
27922718
};
27932719

27942720
/*

0 commit comments

Comments
 (0)