new version, hope this one will works everywhere… seems that FF always hang few second, IE & Safari seems OK…
Waiting feedback from MAC & Linux users please.
demo using this loader:
http://demo.dzzd.net/EARTH/
http://demo.dzzd.net/JScripts/index2.htm
http://demo.dzzd.net/JScripts/
/**
* 3DzzDAppletScript.js
*
* This source code is a part of 3DzzD Web 3D engine you may use it as long as you provide the orignal source author and website and this comment unmodified
*
* @author bruno augier
* @email bruno.augier@dzzd.net
* @website http://dzzd.net/
* @version 1.00 2007/12/03
*/
var jvmInited=false;
var imageLoad=new Image();
imageLoad.src="INIT.GIF";
var preloadingJar = new Array();
function loadApplet(targetAppletId,appletName,appletTag,width,height,preloadJarFiles)
{
if(document.getElementById(appletName))
return;
var msg="Loading Applet "+ appletName;
window.status=msg;
var target=document.getElementById(targetAppletId);
var html="";
html+="<TABLE ID=\""+targetAppletId+"LOADER\" cellSpacing=0 cellPadding=0 WIDTH=\""+width+"\" HEIGHT=\""+height+"\" STYLE=\"border:0\" >";
html+="<TR><TD vAlign=\"center\" align=\"middle\">";
html+="<IMG ";
html+=" ALT=\""+ msg + "\" ";
html+=" SRC=\"INIT.GIF\" ";
html+=" >";
html+="</TD></TR></TABLE><DIV STYLE=\"visibility:hidden\" ID=\""+targetAppletId+"APPLET\"></DIV>";
target.innerHTML=html;
var nbApplet=document.applets.length;
if(preloadJarFiles!=null && preloadJarFiles.replace(" ","")!="")
{
preloadJars(preloadJarFiles);
setTimeout("showAppletOnceStartedPreload(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\",\""+preloadJarFiles+"\","+nbApplet+")",100);
}
else
{
setTimeout("showAppletOnceStarted(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\","+nbApplet+")",100);
}
}
function showAppletOnceStartedPreload(targetAppletId,appletName,appletTag,width,height,preloadJarFiles,nbApplet)
{
if(!isJarsPreloaded(preloadJarFiles))
setTimeout("showAppletOnceStartedPreload(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\",\""+preloadJarFiles+"\","+nbApplet+")",1250);
else
setTimeout("showAppletOnceStarted(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\","+nbApplet+")",250);
}
function showAppletOnceStarted(targetAppletId,appletName,appletTag,width,height,nbApplet)
{
var target=document.getElementById(targetAppletId+"APPLET");
if(target.innerHTML.toUpperCase().indexOf("<APPLET ")==-1)
{
target.innerHTML+=appletTag;
setTimeout("showAppletOnceStarted(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\","+nbApplet+")",250);
return;
}
if(jvmInited)
{
if(document.applets.length>nbApplet)
{
var applet=document.getElementById(appletName);
if(applet!=null)
{
if(document.applets[appletName])
{
var msg="Applet loaded and started " + appletName;
window.status=msg;
setTimeout("showApplet(\""+targetAppletId+"\",\""+appletName+"\",\""+width+"\",\""+height+"\")",250);
return;
}
}
}
}
setTimeout("showAppletOnceStarted(\""+targetAppletId+"\",\""+appletName+"\",\""+appletTag+"\",\""+width+"\",\""+height+"\","+nbApplet+")",250);
}
function showApplet(targetAppletId,appletName,width,height)
{
var applet=document.getElementById(appletName);
var loader=document.getElementById(targetAppletId+"LOADER");
loader.style.display="none";
applet.width=width;
applet.height=height;
applet.style.width=width;
applet.style.height=height;
var target=document.getElementById(targetAppletId+"APPLET");
target.style.visibility="visible";
}
function preloadJars(files)
{
var fileArray=files.replace(";",",").split(",");
for(var c=0;c<fileArray.length;c++)
{
preloadJar(fileArray[c]);
}
}
function isJarsPreloaded(files)
{
var fileArray=files.replace(";",",").split(",");
for(var c=0;c<fileArray.length;c++)
{
if(!fileArray[c])
return false;
}
return true;
}
function isJarPreloaded(name)
{
if(preloadingJar[name]==null)
return false;
return preloadingJar[name];
}
function preloadJar(name)
{
if(preloadingJar[name])
return;
preloadingJar[name]=false;
var f=window.frames[name];
if(!f)
{
document.body.innerHTML+="<IFRAME NAME=\""+name+"\" WIDTH=0 HEIGHT=0 STYLE=\"border:0\"></IFRAME>";
f=window.frames[name];
f.document.open("text/html");
var iframeHTML="";
iframeHTML+="<HTML><BODY onload=\"parent.preloadingJar['"+name+"']=true;\" SCROLL=NO STYLE=\"margin:0\" >";
iframeHTML+="<APPLET ARCHIVE=\""+name+"\" NAME=\""+name+"\" WIDTH=0 HEIGHT=0 ";
iframeHTML+=" CODE = \"java.applet.Applet\" ";
iframeHTML+="</APPLET>";
iframeHTML+="</BODY></HTML>";
f.document.write(iframeHTML);
f.document.close();
}
}
var initJVMCount=0;
/**
* Initialise Java JVM, this may hang few seconds
*/
function loadJVM()
{
if(jvmInited)
return;
if(initJVMCount>15)
{
if(confirm("Java Plugin requiered, do you want to instal Java Plugin ?"))
window.location.href="http://java.com/";
jvmInited=true;
return;
}
var f=window.frames["JVMLOADER"];
if(!f)
{
document.body.innerHTML+="<IFRAME NAME=\"JVMLOADER\" WIDTH=0 HEIGHT=0 STYLE=\"border:0\"></IFRAME>";
f=window.frames["JVMLOADER"];
f.document.open("text/html");
var iframeHTML="";
iframeHTML+="<HTML><BODY SCROLL=NO STYLE=\"margin:0\" >";
iframeHTML+="<APPLET WIDTH=0 HEIGHT=0 ";
iframeHTML+=" CODE = \"java.applet.Applet\" ";
iframeHTML+="</APPLET>";
iframeHTML+="</BODY></HTML>";
f.document.write(iframeHTML);
f.document.close();
}
if(f.document.applets.length==0)
{
setTimeout("loadJVM()",2000);
initJVMCount++;
return;
}
// Workaround for Safari 3.0.4 embeded code crash windows XP with safari ?!
if(navigator.userAgent.toUpperCase().indexOf("SAFARI")==-1)
{
try
{
if(!f.document.applets[0].isActive())
{
setTimeout("loadJVM()",500);
initJVMCount++;
return;
}
}
catch(e)
{
setTimeout("loadJVM()",500);
initJVMCount++;
return;
}
}
jvmInited=true;
f.document.open("text/html");
var iframeHTML="";
iframeHTML+="<HTML><BODY SCROLL=NO STYLE=\"margin:0\" >";
iframeHTML+="</BODY></HTML>";
f.document.write(iframeHTML);
f.document.close();
}