Author: nextgens
Date: 2007-12-16 21:37:27 +0000 (Sun, 16 Dec 2007)
New Revision: 16613
Added:
trunk/website/PluginDetect.js
Modified:
trunk/website/index.php
trunk/website/pages/en/download.php
Log:
website: import some 3rd party code to detect the presence of the jvm
Added: trunk/website/PluginDetect.js
===================================================================
--- trunk/website/PluginDetect.js (rev 0)
+++ trunk/website/PluginDetect.js 2007-12-16 21:37:27 UTC (rev 16613)
@@ -0,0 +1 @@
+/* PluginDetect v0.1.9 by Eric Gerds */ var
PluginDetect={minIEver:5.5,getNum:function(A){if(!A){return null}var
m=/[\d][\d\.\_,-]*/.exec(A);return
m?m[0].replace(/[\.\_-]/g,","):null},hasMimeType:function(_3){var
s,t,z,M=_3.constructor==String?[_3]:_3;for(z=0;z<M.length;z++){s=navigator.mimeTypes[M[z]];if(s&&s.enabledPlugin){t=s.enabledPlugin;if(t.name||t.description){return
s}}}return null},findNavPlugin:function(N,_6){var
_7=N.constructor==String?N:N.join(".*"),numS=_6===false?"":"\\d";var i,re=new
RegExp(_7+".*"+numS+"|"+numS+".*"+_7,"i");var
_9=navigator.plugins;for(i=0;i<_9.length;i++){if(re.test(_9[i].description)||re.test(_9[i].name)){return
_9[i]}}return null},getAXO:function(_a){var _b,e;try{_b=new
ActiveXObject(_a);return _b}catch(e){}return null},num:function(A){return
(typeof
A!="string"?false:(/\d/).test(A))},compareNums:function(_d,_e){if(!this.num(_d)||!this.num(_e)){return
0}var
m1=_d.split(","),m2=_e.split(","),x,p=parseInt;for(x=0;x<Math.min(m1.length,m2.length);x++){if(p(m1[x],10)>p(m2[x],10)){return
1}if(p(m1[x],10)<p(m2[x],10)){return -1}}return
0},formatNum:function(num){if(!this.num(num)){return null}var
n=num.replace(/[\.\_]/g,","),i;n=n.split(",").concat(["0","0","0","0"]);return
n.slice(0,4).join(",")},initScript:function(){var
$=this,IE;$.isIE=(/*@cc_on!@*/false);$.IEver=-1;if($.isIE){var
IE=(/msie\s*\d\.{0,1}\d*/i).exec(navigator.userAgent),progid,x;if(IE){$.IEver=parseFloat((/\d.{0,1}\d*/i).exec(IE[0]),10)}progid=["ShockwaveFlash.ShockwaveFlash","Msxml2.XMLHTTP","Microsoft.XMLDOM","Msxml2.DOMDocument","TDCCtl.TDCCtl","Shell.UIHelper","Scripting.Dictionary"];$.ActiveXEnabled=false;for(x=0;x<progid.length;x++){if($.getAXO(progid[x])){$.ActiveXEnabled=true;break}}};if($.ActiveXEnabled&&$.IEver>=$.minIEver){$.head=typeof
document.getElementsByTagName!="undefined"?document.getElementsByTagName("head")[0]:null;var
T=document.createElement("script");T.setAttribute("type","text/vbscript");var
Y=["<!"+"--","function PluginDetect1(c)","on error resume
next","PluginDetect1=false","dim head, r","set head=PluginDetect.head","set
r=head.firstChild","if TypeName(r)=\"HTMLObjectElement\" then","r.setAttribute
\"classid\", c","if not TypeName(r.getAttribute(\"object\")) = \"Nothing\"
then","PluginDetect1=true","if r.getAttribute(\"readyState\")<4
then","r.clearAttributes()","head.removeChild(r)","end if","else
r.clearAttributes()","head.removeChild(r)","end if","end
if","r=\"Nothing\"","head=\"Nothing\"","end
function","--"+">"];T.setAttribute("text",Y.join("\n"));if($.head.firstChild){$.head.insertBefore(T,$.head.firstChild)}else{$.head.appendChild(T)}$.vbscript=false;var
e;$.head.insertBefore(document.createElement("object"),$.head.firstChild);try{if(PluginDetect1("")===false){$.vbscript=true}}catch(e){}}},init:function(_17){var
$=this,IE,p;_17=_17.toLowerCase().replace(/\s/g,"");p=$.plugin=$[_17];if(!p){return
-3}if(typeof p.minversion=="undefined"){p.minversion={}}if(typeof
p.version=="undefined"){p.version=null}if(typeof
p.installed=="undefined"){p.installed=null}$.garbage=false;if($.isIE&&!$.ActiveXEnabled){return
-2}return 1},isMinVersion:function(_19,_1a){var
$=PluginDetect,i=$.init(_19);if(i<0){return i}if(!$.num(_1a)){return -3}var
p=$.plugin,m=p.minversion;_1a=$.formatNum(_1a);if(typeof
m["a"+_1a]=="undefined"){if(p.installed==null&&p.getCodeBaseVersion&&$.IEver>=p.minIEver){var
tmp,x;for(x in
m){tmp=$.compareNums(_1a,x.substring(1,x.length));if(m[x]==1&&tmp<=0){return
1}if(m[x]==-1&&tmp>=0){return
-1}}m["a"+_1a]=$.isActiveXObject(_1a)?1:-1}else{if(p.installed==null){p.getVersion()}if(p.installed==-1){m["a"+_1a]=-1}else{if(p.version==null){m["a"+_1a]=0}else{m["a"+_1a]=($.compareNums(p.version,_1a)>=0?1:-1)}}}}$.cleanup();return
m["a"+_1a];return -3},getVersion:function(_1e){return
null},cleanup:function(){var $=this;if($.garbage&&typeof
window.CollectGarbage!="undefined"){window.CollectGarbage()}},isActiveXObject:function(_22){var
$=this,result,s="<object width=\"1\" height=\"1\" "+"style=\"display:none\"
"+$.plugin.getCodeBaseVersion(_22)+">"+$.plugin.HTML+"</object>";$.head.insertBefore(document.createElement("object"),$.head.firstChild);$.head.firstChild.outerHTML=s;result=$.vbscript?PluginDetect1($.plugin.classID):$.detect($.plugin.classID);return
result},detect:function(_24){var
$=this,result;$.head.firstChild.setAttribute("classid",_24);result=$.head.firstChild.getAttribute("object")?true:false;if(!result||$.head.firstChild.getAttribute("readyState")<4){$.head.firstChild.clearAttributes();$.head.removeChild($.head.firstChild);$.garbage=true}return
result},search:function(){},dummy1:0};PluginDetect.initScript();PluginDetect.java={mimeType:"application/x-java-applet",classID:"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93",JavaVersions:["1.7.0.15","1.6.0.15","1.5.0.14","1.4.2.13","1.3.1.18"],searchJava:function(M){if(!M){return
null}var G,e,x3,x4;var AXO=ActiveXObject;var
T=M.split("."),J="JavaPlugin."+T[0]+T[1],v=T[0]+"."+T[1]+".";for(x3=T[2];x3>=0;x3--){for(x4=T[3];x4>=0;x4--){G=x4<10?"0"+x4:x4;try{new
AXO(J+x3+"_"+G);return v+x3+"_"+G}catch(e){}}if(J+x3=="JavaPlugin.131"){return
null}try{new AXO(J+x3);return v+x3}catch(e){}}return
null},minIEver:5.5,HTML:"<param name=\"code\" value=\"A14999.class\"
/>",getCodeBaseVersion:function(v){var
r=this.getDigits(v),$=PluginDetect;if($.compareNums(v,"1,4,1,02")<0){v=r[0]+","+r[1]+","+r[2]+","+r[3]}else{if($.compareNums(v,"1,5,0,02")<0){v=r[0]+","+r[1]+","+r[2]+","+r[3]+"0"}else{v=Math.round((parseFloat(r[0]+"."+r[1],10)-1.5)*10+5)+","+r[2]+","+r[3]+"0"+",0"}}return
"codebase=\"#version="+v+"\""},digits:[1,9,32,32],getDigits:function(n){/([\d]+)[,_\.]([\d]+)[,_\.]([\d]+)[,_\.]([\d]+)/.test(n);return
[RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$4]},hasRun:false,value:null,queryJavaHandler:function(){var
$=PluginDetect.java,j=window.java,e;$.hasRun=true;try{if(typeof
j.lang!="undefined"&&typeof
j.lang.System!="undefined"){$.value=j.lang.System.getProperty("java.version")+"
"}}catch(e){}},queryJava:function(){var
$=PluginDetect,t=this,nua=navigator.userAgent,e;if(typeof
window.java!="undefined"&&window.navigator.javaEnabled()){if(/gecko/i.test(nua)){if($.hasMimeType("application/x-java-vm")){try{var
div=document.createElement("div"),evObj=document.createEvent("HTMLEvents");evObj.initEvent("focus",false,true);div.addEventListener("focus",t.queryJavaHandler,false);div.dispatchEvent(evObj)}catch(e){}if(!t.hasRun){t.queryJavaHandler()}}}else{if(/opera.9\.(0|1)/i.test(nua)&&/mac/i.test(nua)){return
null}t.queryJavaHandler()}}return t.value},getVersion:function(){var
_3a=null,$=PluginDetect;if(!$.isIE){var
p1,p,mt;p=$.findNavPlugin(["Java","Plug-in"]);mt=$.hasMimeType(this.mimeType);if(p){p1=$.getNum(p.description)}if(p1&&mt&&navigator.javaEnabled()){_3a=p1}if(!_3a){p=this.queryJava();if(p){_3a=p}}this.installed=-1;if(_3a){this.installed=1}else{if(mt&&navigator.javaEnabled()){if(/macintosh/i.test(navigator.userAgent)&&/safari/i.test(navigator.userAgent)){this.installed=0}}}}else{var
x,tmp=null;if($.IEver>=this.minIEver){_3a=$.search();this.installed=_3a?1:-1}else{for(x=0;x<this.JavaVersions.length;x++){tmp=this.searchJava(this.JavaVersions[x]);if(tmp){_3a=tmp;break}}this.installed=_3a?1:($.getAXO("JavaPlugin")?0:-1)}}this.version=$.formatNum($.getNum(_3a))}};
Modified: trunk/website/index.php
===================================================================
--- trunk/website/index.php 2007-12-16 21:26:08 UTC (rev 16612)
+++ trunk/website/index.php 2007-12-16 21:37:27 UTC (rev 16613)
@@ -15,7 +15,7 @@
<meta name="description" content="The Free Network Project : A
Distributed Anonymous Information Storage and Retrieval System" />
<link href="/style.css" rel="stylesheet" type="text/css">
- <script language="javascript">
+ <script language="text/javascript">
function toggleLayer( whichLayer )
{
var elem, vis;
@@ -32,6 +32,7 @@
vis.display =
(vis.display==''||vis.display=='block')?'none':'block';
}
</script>
+ <script type="text/javascript" src="PluginDetect.js">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#000033"
alink="#000000" leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>
Modified: trunk/website/pages/en/download.php
===================================================================
--- trunk/website/pages/en/download.php 2007-12-16 21:26:08 UTC (rev 16612)
+++ trunk/website/pages/en/download.php 2007-12-16 21:37:27 UTC (rev 16613)
@@ -14,7 +14,11 @@
href="/faq.html#firewall"><b>here</b></a>
for some info.</i> <BR> <BR>
-<script language="javascript">
+<script language="javascript"><!--
+ // Try to detect if Sun Java 1.4.2 or higher is installed
+ minVersion = '1,4,2'
+ var Java = PluginDetect.isMinVersion('Java', minVersion);
+
// Os detection
var OSName="";
if (navigator.appVersion.indexOf("Win")!=-1)
@@ -25,14 +29,15 @@
OSName="unix";
else if (navigator.appVersion.indexOf("Linux")!=-1)
OSName="unix";
+
- if(navigator.javaEnabled())
+ if(Java > 1)
toggleLayer("jws");
else if (OSName != "") {
toggleLayer("nojws");
toggleLayer(OSName);
}
-</script>
+//--></script>
<div class="hideit" id="jws">
<h2>Installation Instructions</h2>
Clicking the <big><big><a
href="http://downloads.freenetproject.org/alpha/installer/mac/freenet.jnlp">Install
Freenet 0.7</a></big></big> link should start the installer up. If it doesn't
work for some reason, you can try the platform specific instructions (<a
href="javascript:toggleLayer('windows');">Windows instructions</a>, <a
href="javascript:toggleLayer('macos');">Mac OSX instructions</a>, <a
href="javascript:toggleLayer('unix');">Unix/Linux instructions</a>).