|
98 | 98 | * HTTP connections timeout, but should not accur in local file system, or it |
99 | 99 | * is a loading bug by using JavaScript timeout thread). |
100 | 100 | */ |
101 | | - |
| 101 | + |
| 102 | +/* |
| 103 | + * The following comments with "#" are special configurations for a much |
| 104 | + * smaller *.js file size. |
| 105 | + * |
| 106 | + *@see net.sf.j2s.lib/src/net/sf/j2s/lib/build/SmartJSCompressor.java |
| 107 | + */ |
102 | 108 | /*-# |
103 | 109 | # ClazzNode -> $CN$ |
104 | 110 | # ClazzLoader -> $CL$ |
@@ -186,13 +192,18 @@ ClazzLoader.inLoadingThreads = 0; |
186 | 192 | /* protected */ |
187 | 193 | ClazzLoader.maxLoadingThreads=6; |
188 | 194 |
|
| 195 | +ClazzLoader.userAgent=navigator.userAgent.toLowerCase(); |
| 196 | +ClazzLoader.isOpera=(ClazzLoader.userAgent.indexOf("opera")!=-1); |
| 197 | +ClazzLoader.isIE=(ClazzLoader.userAgent.indexOf("msie")!=-1)&&!ClazzLoader.isOpera; |
| 198 | +ClazzLoader.isGecko=(ClazzLoader.userAgent.indexOf("gecko")!=-1); |
| 199 | + |
189 | 200 | /* |
190 | 201 | * Opera has different loading order which will result in performance degrade! |
191 | 202 | * So just return to single thread loading in Opera! |
192 | 203 | * |
193 | 204 | * FIXME: This different loading order also causes bugs in single thread! |
194 | 205 | */ |
195 | | -if(navigator.userAgent.toLowerCase().indexOf("opera")!=-1){ |
| 206 | +if(ClazzLoader.isOpera){ |
196 | 207 | ClazzLoader.maxLoadingThreads=1; |
197 | 208 | } |
198 | 209 |
|
@@ -907,8 +918,7 @@ ClazzLoader.loadScript = function (file) { |
907 | 918 | } |
908 | 919 | this.onload=null; |
909 | 920 | varpath=arguments.callee.path; |
910 | | -if(!ClazzLoader.innerLoadedScripts[this.src] |
911 | | -&&navigator.userAgent.indexOf("Opera")>=0){ |
| 921 | +if(!ClazzLoader.innerLoadedScripts[this.src]&&ClazzLoader.isOpera){ |
912 | 922 | // Opera will not take another try. |
913 | 923 | varfss=ClazzLoader.failedScripts; |
914 | 924 | if(fss[path]==null&&ClazzLoader.takeAnotherTry){ |
@@ -972,7 +982,7 @@ ClazzLoader.loadScript = function (file) { |
972 | 982 | ClazzLoader.removeScriptNode(this); |
973 | 983 | }; |
974 | 984 | script.onerror.path=file; |
975 | | -if(navigator.userAgent.indexOf("Opera")>=0){ |
| 985 | +if(ClazzLoader.isOpera){ |
976 | 986 | ClazzLoader.needOnloadCheck=true; |
977 | 987 | } |
978 | 988 | }else{// IE |
@@ -1152,7 +1162,7 @@ ClazzLoader.tryToLoadNext = function (file) { |
1152 | 1162 | */ |
1153 | 1163 | if(ClazzLoader.lockQueueBe4SWT&&ClazzLoader.pkgRefCount!=0 |
1154 | 1164 | &&file.lastIndexOf("package.js")!=file.length-10 |
1155 | | -&&navigator.userAgent.toLowerCase().indexOf("gecko")!=-1){ |
| 1165 | +&&(ClazzLoader.isGecko||ClazzLoader.isIE)){// No Opera! |
1156 | 1166 | varqbs=ClazzLoader.queueBe4SWT; |
1157 | 1167 | qbs[qbs.length]=file; |
1158 | 1168 | return; |
@@ -1245,12 +1255,13 @@ ClazzLoader.tryToLoadNext = function (file) { |
1245 | 1255 | if(cq.length!=0){ |
1246 | 1256 | /* queue must be loaded in order! */ |
1247 | 1257 | n=cq[0];// popup class from the queue |
| 1258 | +//alert ("load from queue"); |
| 1259 | +//alert (cq.length + ":" + cq); |
1248 | 1260 | for(vari=0;i<cq.length-1;i++){ |
1249 | 1261 | cq[i]=cq[i+1]; |
1250 | 1262 | } |
1251 | 1263 | cq.length--; |
1252 | | - |
1253 | | -//alert ("load from queue"); |
| 1264 | +//log (cq.length + ":" + cq); |
1254 | 1265 | if(!ClazzLoader.loadedScripts[n.path]||cq.length!=0 |
1255 | 1266 | ||!ClazzLoader.isLoadingEntryClass |
1256 | 1267 | ||(n.musts!=null&&n.musts.length!=0) |
@@ -1779,7 +1790,7 @@ ClazzLoader.checkInteractive = function () { |
1779 | 1790 | &&ss[i].onreadystatechange!=null){// IE |
1780 | 1791 | ClazzLoader.interactiveScript=ss[i]; |
1781 | 1792 | ClazzLoader.innerLoadedScripts[ss[i].src]=true; |
1782 | | -}elseif(navigator.userAgent.indexOf("Opera")>=0){// Opera |
| 1793 | +}elseif(ClazzLoader.isOpera){// Opera |
1783 | 1794 | if(ss[i].readyState=="loaded" |
1784 | 1795 | &&ss[i].src!=null&&ss[i].src.length!=0){ |
1785 | 1796 | ClazzLoader.innerLoadedScripts[ss[i].src]=true; |
@@ -2053,6 +2064,13 @@ ClazzLoader.queueBe4KeyClazz = new Array (); |
2053 | 2064 | /* private */ |
2054 | 2065 | /*-# getJ2SLibBase -> gLB #-*/ |
2055 | 2066 | ClazzLoader.getJ2SLibBase=function(){ |
| 2067 | +varo=window["j2s.lib"]; |
| 2068 | +if(o!=null){ |
| 2069 | +if(o.base==null){ |
| 2070 | +o.base="http://archive.java2script.org/"; |
| 2071 | +} |
| 2072 | +returno.base+(o.alias ?o.alias :(o.version ?o.version :"1.0.0"))+"/"; |
| 2073 | +} |
2056 | 2074 | varss=document.getElementsByTagName("SCRIPT"); |
2057 | 2075 | for(vari=0;i<ss.length;i++){ |
2058 | 2076 | varsrc=ss[i].src; |
@@ -2154,23 +2172,32 @@ ClazzLoader.loadClass = function (name, optionalsLoaded, forced, async) { |
2154 | 2172 | /*-# needBeingQueued -> nQ #-*/ |
2155 | 2173 | varneedBeingQueued=false; |
2156 | 2174 | varqq=ClazzLoader.classQueue; |
| 2175 | +//error (qq.length + ":" + qq); |
| 2176 | +//error (path); |
2157 | 2177 | for(vari=qq.length-1;i>=0;i--){ |
2158 | 2178 | if(qq[i].status!=ClazzNode.STATUS_OPTIONALS_LOADED){ |
2159 | 2179 | needBeingQueued=true; |
2160 | 2180 | break; |
2161 | 2181 | } |
2162 | 2182 | } |
2163 | | -/* |
2164 | | -if (forced) { |
| 2183 | +if(path.lastIndexOf("package.js")==path.length-10){//forced |
2165 | 2184 | // push class to queue |
| 2185 | +varinserted=false; |
2166 | 2186 | for(vari=qq.length-1;i>=0;i--){ |
| 2187 | +varname=qq[i].name; |
| 2188 | +if(name.lastIndexOf("package.js")==name.length-10){ |
| 2189 | +qq[i+1]=n; |
| 2190 | +inserted=true; |
| 2191 | +break; |
| 2192 | +} |
2167 | 2193 | qq[i+1]=qq[i]; |
2168 | 2194 | } |
2169 | | -qq[0] = n; |
| 2195 | +if(!inserted){ |
| 2196 | +qq[0]=n; |
| 2197 | +} |
2170 | 2198 | }else{ |
2171 | | -//*/ |
2172 | 2199 | qq[qq.length]=n; |
2173 | | -//} |
| 2200 | +} |
2174 | 2201 | if(!needBeingQueued){// can be loaded directly |
2175 | 2202 | /*-# bakEntryClassLoading -> bkECL #-*/ |
2176 | 2203 | varbakEntryClassLoading=false; |
|