deployJava.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  1. var deployJava={
  2. debug:null,
  3. firefoxJavaVersion:null,
  4. myInterval:null,
  5. preInstallJREList:null,
  6. returnPage:null,
  7. brand:null,
  8. locale:null,
  9. installType:null,
  10. EAInstallEnabled:false,
  11. EarlyAccessURL:null,
  12. getJavaURL:'http://www.java.com/ko/?',
  13. appleRedirectPage:'http://www.apple.com/support/downloads/',
  14. oldMimeType:'application/npruntime-scriptable-plugin;DeploymentToolkit',
  15. mimeType:'application/java-deployment-toolkit',
  16. launchButtonPNG:'http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png',
  17. browserName:null,
  18. browserName2:null,
  19. getJREs:function()
  20. {
  21. var list=new Array();
  22. if(deployJava.isPluginInstalled())
  23. {
  24. var plugin=deployJava.getPlugin();
  25. var VMs=plugin.jvms;
  26. for(var i=0;i<VMs.getLength();i++)
  27. {
  28. list[i]=VMs.get(i).version;
  29. }
  30. }
  31. else
  32. {
  33. var browser=deployJava.getBrowser();
  34. if(browser=='MSIE')
  35. {
  36. if(deployJava.testUsingActiveX('1.7.0'))
  37. {
  38. list[0]='1.7.0';
  39. }
  40. else if(deployJava.testUsingActiveX('1.6.0'))
  41. {
  42. list[0]='1.6.0';
  43. }
  44. else if(deployJava.testUsingActiveX('1.5.0'))
  45. {
  46. list[0]='1.5.0';
  47. }
  48. else if(deployJava.testUsingActiveX('1.4.2'))
  49. {
  50. list[0]='1.4.2';
  51. }
  52. else if(deployJava.testForMSVM())
  53. {
  54. list[0]='1.1';
  55. }
  56. }
  57. else if(browser=='Netscape Family')
  58. {
  59. deployJava.getJPIVersionUsingMimeType();
  60. if(deployJava.firefoxJavaVersion!=null)
  61. {
  62. list[0]=deployJava.firefoxJavaVersion;
  63. }
  64. else if(deployJava.testUsingMimeTypes('1.7'))
  65. {
  66. list[0]='1.7.0';
  67. }
  68. else if(deployJava.testUsingMimeTypes('1.6'))
  69. {
  70. list[0]='1.6.0';
  71. }
  72. else if(deployJava.testUsingMimeTypes('1.5'))
  73. {
  74. list[0]='1.5.0';
  75. }
  76. else if(deployJava.testUsingMimeTypes('1.4.2'))
  77. {
  78. list[0]='1.4.2';
  79. }
  80. else if(deployJava.browserName2=='Safari')
  81. {
  82. if(deployJava.testUsingPluginsArray('1.7.0'))
  83. {
  84. list[0]='1.7.0';
  85. }
  86. else if(deployJava.testUsingPluginsArray('1.6'))
  87. {
  88. list[0]='1.6.0';
  89. }
  90. else if(deployJava.testUsingPluginsArray('1.5'))
  91. {
  92. list[0]='1.5.0';
  93. }
  94. else if(deployJava.testUsingPluginsArray('1.4.2'))
  95. {
  96. list[0]='1.4.2';
  97. }
  98. }
  99. }
  100. }
  101. if(deployJava.debug)
  102. {
  103. for(var i=0;i<list.length;++i)
  104. {
  105. alert('We claim to have detected Java SE '+list[i]);
  106. }
  107. }
  108. return list;
  109. }
  110. ,installJRE:function(requestVersion)
  111. {
  112. var ret=false;
  113. if(deployJava.isPluginInstalled())
  114. {
  115. if(deployJava.getPlugin().installJRE(requestVersion))
  116. {
  117. deployJava.refresh();
  118. if(deployJava.returnPage!=null)
  119. {
  120. document.location=deployJava.returnPage;
  121. }
  122. return true;
  123. }
  124. else
  125. {
  126. return false;
  127. }
  128. }
  129. else
  130. {
  131. return deployJava.installLatestJRE();
  132. }
  133. }
  134. ,installLatestJRE:function()
  135. {
  136. if(deployJava.isPluginInstalled())
  137. {
  138. if(deployJava.getPlugin().installLatestJRE())
  139. {
  140. deployJava.refresh();
  141. if(deployJava.returnPage!=null)
  142. {
  143. document.location=deployJava.returnPage;
  144. }
  145. return true;
  146. }
  147. else
  148. {
  149. return false;
  150. }
  151. }
  152. else
  153. {
  154. var browser=deployJava.getBrowser();
  155. var platform=navigator.platform.toLowerCase();
  156. if((deployJava.EAInstallEnabled=='true')&&(platform.indexOf('win')!=-1)&&(deployJava.EarlyAccessURL!=null))
  157. {
  158. deployJava.preInstallJREList=deployJava.getJREs();
  159. if(deployJava.returnPage!=null)
  160. {
  161. deployJava.myInterval=setInterval("deployJava.poll()",3000);
  162. }
  163. location.href=deployJava.EarlyAccessURL;
  164. return false;
  165. }
  166. else
  167. {
  168. if(browser=='MSIE')
  169. {
  170. return deployJava.IEInstall();
  171. }
  172. else if((browser=='Netscape Family')&&(platform.indexOf('win32')!=-1))
  173. {
  174. return deployJava.FFInstall();
  175. }
  176. else
  177. {
  178. location.href=deployJava.getJavaURL+
  179. ((deployJava.returnPage!=null)?('&returnPage='+deployJava.returnPage):'')+
  180. ((deployJava.locale!=null)?('&locale='+deployJava.locale):'')+
  181. ((deployJava.brand!=null)?('&brand='+deployJava.brand):'');
  182. }
  183. return false;
  184. }
  185. }
  186. }
  187. ,runApplet:function(attributes,parameters,minimumVersion)
  188. {
  189. if(minimumVersion=='undefined'||minimumVersion==null)
  190. {
  191. minimumVersion='1.1';
  192. }
  193. var regex="^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
  194. var matchData=minimumVersion.match(regex);
  195. if(deployJava.returnPage==null)
  196. {
  197. deployJava.returnPage=document.location;
  198. }
  199. if(matchData!=null)
  200. {
  201. var browser=deployJava.getBrowser();
  202. if((browser!='?')&&('Safari'!=deployJava.browserName2))
  203. {
  204. if(deployJava.versionCheck(minimumVersion+'+'))
  205. {
  206. deployJava.writeAppletTag(attributes,parameters);
  207. }
  208. else if(deployJava.installJRE(minimumVersion+'+'))
  209. {
  210. deployJava.refresh();
  211. location.href=document.location;
  212. deployJava.writeAppletTag(attributes,parameters);
  213. }
  214. else
  215. {
  216. deployJava.writeAppletTag(attributes,parameters);
  217. }
  218. }
  219. }
  220. else
  221. {
  222. if(deployJava.debug)
  223. {
  224. alert('Invalid minimumVersion argument to runApplet():'+
  225. minimumVersion);
  226. }
  227. }
  228. }
  229. ,writeAppletTag:function(attributes,parameters)
  230. {
  231. var s='<'+'applet ';
  232. var codeAttribute=false;
  233. for(var attribute in attributes)
  234. {
  235. s+=(' '+attribute+'="'+attributes[attribute]+'"');
  236. if(attribute=='code')
  237. {
  238. codeAttribute=true;
  239. }
  240. }
  241. if(!codeAttribute)
  242. {
  243. s+=(' code="dummy"');
  244. }
  245. s+='>';
  246. document.write(s);
  247. if(parameters!='undefined'&&parameters!=null)
  248. {
  249. var codebaseParam=false;
  250. for(var parameter in parameters)
  251. {
  252. if(parameter=='codebase_lookup')
  253. {
  254. codebaseParam=true;
  255. }
  256. s='<param name="'+parameter+'" value="'+
  257. parameters[parameter]+'">';
  258. document.write(s);
  259. }
  260. if(!codebaseParam)
  261. {
  262. document.write('<param name="codebase_lookup" value="false">');
  263. }
  264. }
  265. document.write('<'+'/'+'applet'+'>');
  266. }
  267. ,versionCheck:function(versionPattern)
  268. {
  269. var index=0;
  270. var regex="^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?(\\*|\\+)?$";
  271. var matchData=versionPattern.match(regex);
  272. if(matchData!=null)
  273. {
  274. var familyMatch=true;
  275. var patternArray=new Array();
  276. for(var i=1;i<matchData.length;++i)
  277. {
  278. if((typeof matchData[i]=='string')&&(matchData[i]!=''))
  279. {
  280. patternArray[index]=matchData[i];
  281. index++;
  282. }
  283. }
  284. if(patternArray[patternArray.length-1]=='+')
  285. {
  286. familyMatch=false;
  287. patternArray.length--;
  288. }
  289. else
  290. {
  291. if(patternArray[patternArray.length-1]=='*')
  292. {
  293. patternArray.length--;
  294. }
  295. }
  296. var list=deployJava.getJREs();
  297. for(var i=0;i<list.length;++i)
  298. {
  299. if(deployJava.compareVersionToPattern(list[i],patternArray,familyMatch))
  300. {
  301. return true;
  302. }
  303. }
  304. return false;
  305. }
  306. else
  307. {
  308. alert('Invalid versionPattern passed to versionCheck: '+
  309. versionPattern);
  310. return false;
  311. }
  312. }
  313. ,isWebStartInstalled:function(minimumVersion)
  314. {
  315. var browser=deployJava.getBrowser();
  316. if((browser=='?')||('Safari'==deployJava.browserName2))
  317. {
  318. return true;
  319. }
  320. if(minimumVersion=='undefined'||minimumVersion==null)
  321. {
  322. minimumVersion='1.4.2';
  323. }
  324. var retval=false;
  325. var regex="^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
  326. var matchData=minimumVersion.match(regex);
  327. if(matchData!=null)
  328. {
  329. retval=deployJava.versionCheck(minimumVersion+'+');
  330. }
  331. else
  332. {
  333. if(deployJava.debug)
  334. {
  335. alert('Invalid minimumVersion argument to isWebStartInstalled(): '+minimumVersion);
  336. }
  337. retval=deployJava.versionCheck('1.4.2+');
  338. }
  339. return retval;
  340. }
  341. ,getJPIVersionUsingMimeType:function()
  342. {
  343. for(var i=0;i<navigator.mimeTypes.length;++i)
  344. {
  345. var s=navigator.mimeTypes[i].type;
  346. var m=s.match(/^application\/x-java-applet;jpi-version=(.*)$/);
  347. if(m!=null)
  348. {
  349. deployJava.firefoxJavaVersion=m[1];
  350. break;
  351. }
  352. }
  353. }
  354. ,launchWebStartApplication:function(jnlp)
  355. {
  356. var uaString=navigator.userAgent.toLowerCase();
  357. deployJava.getJPIVersionUsingMimeType();
  358. if(uaString.indexOf("windows",0)!=-1)
  359. {
  360. if(deployJava.isWebStartInstalled('1.6.0_18')==false)
  361. {
  362. if(deployJava.isPluginInstalled())
  363. {
  364. if(deployJava.installLatestJRE()==false)
  365. {
  366. alert("Java install failed: cannot use launchWebStartApplication function");
  367. return;
  368. }
  369. }
  370. else
  371. {
  372. alert("Please visit java.com to install Java and try again after");
  373. return;
  374. }
  375. }
  376. }
  377. else
  378. {
  379. if(deployJava.firefoxJavaVersion==null)
  380. {
  381. alert("Please visit java.com to install Java and try again after");
  382. return;
  383. }
  384. if(deployJava.firefoxJavaVersion<"1.6.0_18")
  385. {
  386. alert("Please visit java.com to install Java and try again after");
  387. return;
  388. }
  389. }
  390. var jnlpDocbase=null;
  391. if(document.documentURI)
  392. {
  393. jnlpDocbase=document.documentURI;
  394. }
  395. if(jnlpDocbase==null)
  396. {
  397. jnlpDocbase=document.URL;
  398. }
  399. var browser=deployJava.getBrowser();
  400. if(browser=='MSIE')
  401. {
  402. document.write('<'+'object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" '+'width="0" height="0">'+'<'+'PARAM name="launchjnlp" value="'+jnlp+'"'+'>'+'<'+'PARAM name="docbase" value="'+jnlpDocbase+'"'+'>'+'<'+'/'+'object'+'>');
  403. }
  404. else if(browser=='Netscape Family')
  405. {
  406. document.write('<'+'embed type="application/x-java-applet;jpi-version='+
  407. deployJava.firefoxJavaVersion+'" '+'width="0" height="0" '+'launchjnlp="'+jnlp+'"'+'docbase="'+jnlpDocbase+'"'+' />');
  408. }
  409. document.location=jnlpDocbase;
  410. }
  411. ,createWebStartLaunchButtonEx:function(jnlp,minimumVersion)
  412. {
  413. if(deployJava.returnPage==null)
  414. {
  415. deployJava.returnPage=jnlp;
  416. }
  417. var url='javascript:deployJava.launchWebStartApplication(\''+jnlp+'\');';
  418. document.write('<'+'a href="'+url+'" onMouseOver="window.status=\'\'; '+'return true;"><'+'img '+'src="'+deployJava.launchButtonPNG+'" '+'border="0" /><'+'/'+'a'+'>');
  419. }
  420. ,createWebStartLaunchButton:function(jnlp,minimumVersion)
  421. {
  422. if(deployJava.returnPage==null)
  423. {
  424. deployJava.returnPage=jnlp;
  425. }
  426. var url='javascript:'+'if (!deployJava.isWebStartInstalled(&quot;'+
  427. minimumVersion+'&quot;)) {'+'if (deployJava.installLatestJRE()) {'+'if (deployJava.launch(&quot;'+jnlp+'&quot;)) {}'+'}'+'} else {'+'if (deployJava.launch(&quot;'+jnlp+'&quot;)) {}'+'}';
  428. document.write('<'+'a href="'+url+'" onMouseOver="window.status=\'\'; '+'return true;"><'+'img '+'src="'+deployJava.launchButtonPNG+'" '+'border="0" /><'+'/'+'a'+'>');
  429. }
  430. ,launch:function(jnlp)
  431. {
  432. if(deployJava.isPluginInstalled())
  433. {
  434. return deployJava.getPlugin().launch(jnlp);
  435. }
  436. else
  437. {
  438. document.location=jnlp;
  439. return true;
  440. }
  441. }
  442. ,isPluginInstalled:function()
  443. {
  444. var plugin=deployJava.getPlugin();
  445. if(plugin&&plugin.jvms)
  446. {
  447. return true;
  448. }
  449. else
  450. {
  451. return false;
  452. }
  453. }
  454. ,isAutoUpdateEnabled:function()
  455. {
  456. if(deployJava.isPluginInstalled())
  457. {
  458. return deployJava.getPlugin().isAutoUpdateEnabled();
  459. }
  460. return false;
  461. }
  462. ,setAutoUpdateEnabled:function()
  463. {
  464. if(deployJava.isPluginInstalled())
  465. {
  466. return deployJava.getPlugin().setAutoUpdateEnabled();
  467. }
  468. return false;
  469. }
  470. ,setInstallerType:function(type)
  471. {
  472. deployJava.installType=type;
  473. if(deployJava.isPluginInstalled())
  474. {
  475. return deployJava.getPlugin().setInstallerType(type);
  476. }
  477. return false;
  478. }
  479. ,setAdditionalPackages:function(packageList)
  480. {
  481. if(deployJava.isPluginInstalled())
  482. {
  483. return deployJava.getPlugin().setAdditionalPackages(packageList);
  484. }
  485. return false;
  486. }
  487. ,setEarlyAccess:function(enabled)
  488. {
  489. deployJava.EAInstallEnabled=enabled;
  490. }
  491. ,isPlugin2:function()
  492. {
  493. if(deployJava.isPluginInstalled())
  494. {
  495. if(deployJava.versionCheck('1.6.0_10+'))
  496. {
  497. try
  498. {
  499. return deployJava.getPlugin().isPlugin2();
  500. }
  501. catch(err)
  502. {
  503. }
  504. }
  505. }
  506. return false;
  507. }
  508. ,allowPlugin:function()
  509. {
  510. deployJava.getBrowser();
  511. var ret=('Chrome'!=deployJava.browserName2&&'Safari'!=deployJava.browserName2&&'Opera'!=deployJava.browserName2);
  512. return ret;
  513. }
  514. ,getPlugin:function()
  515. {
  516. deployJava.refresh();
  517. var ret=null;
  518. if(deployJava.allowPlugin())
  519. {
  520. ret=document.getElementById('deployJavaPlugin');
  521. }
  522. return ret;
  523. }
  524. ,compareVersionToPattern:function(version,patternArray,familyMatch)
  525. {
  526. var regex="^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$";
  527. var matchData=version.match(regex);
  528. if(matchData!=null)
  529. {
  530. var index=0;
  531. var result=new Array();
  532. for(var i=1;i<matchData.length;++i)
  533. {
  534. if((typeof matchData[i]=='string')&&(matchData[i]!=''))
  535. {
  536. result[index]=matchData[i];
  537. index++;
  538. }
  539. }
  540. var l=Math.min(result.length,patternArray.length);
  541. if(familyMatch)
  542. {
  543. for(var i=0;i<l;++i)
  544. {
  545. if(result[i]!=patternArray[i])return false;
  546. }
  547. return true;
  548. }
  549. else
  550. {
  551. // for(var i=0;i<l;++i)
  552. // {
  553. // if(result[i]<patternArray[i])
  554. // {
  555. // return false;
  556. // }
  557. // else if(result[i]>patternArray[i])
  558. // {
  559. // return true;
  560. // }
  561. // }
  562. // return true;
  563. // modify kj
  564. for (var i = 0; i < l; ++i) {
  565. if (result < patternArray) {
  566. return false;
  567. } else if (result > patternArray) {
  568. return true;
  569. }
  570. }
  571. for (var i = l; i < patternArray.length; ++i) {
  572. if (patternArray != "0") {
  573. return false;
  574. }
  575. }
  576. return true;
  577. }
  578. }
  579. else
  580. {
  581. return false;
  582. }
  583. }
  584. ,getBrowser:function()
  585. {
  586. if(deployJava.browserName==null)
  587. {
  588. var browser=navigator.userAgent.toLowerCase();
  589. if(deployJava.debug)
  590. {
  591. alert('userAgent -> '+browser);
  592. }
  593. if(browser.indexOf('msie')!=-1)
  594. {
  595. deployJava.browserName='MSIE';
  596. deployJava.browserName2='MSIE';
  597. }
  598. else if(browser.indexOf('trident')!=-1)
  599. {
  600. deployJava.browserName='MSIE';
  601. deployJava.browserName2='MSIE';
  602. }
  603. else if(browser.indexOf('firefox')!=-1)
  604. {
  605. deployJava.browserName='Netscape Family';
  606. deployJava.browserName2='Firefox';
  607. }
  608. else if(browser.indexOf('chrome')!=-1)
  609. {
  610. deployJava.browserName='Netscape Family';
  611. deployJava.browserName2='Chrome';
  612. }
  613. else if(browser.indexOf('safari')!=-1)
  614. {
  615. deployJava.browserName='Netscape Family';
  616. deployJava.browserName2='Safari';
  617. }
  618. else if(browser.indexOf('mozilla')!=-1)
  619. {
  620. deployJava.browserName='Netscape Family';
  621. deployJava.browserName2='Other';
  622. }
  623. else if(browser.indexOf('opera')!=-1)
  624. {
  625. deployJava.browserName='Netscape Family';
  626. deployJava.browserName2='Opera';
  627. }
  628. else
  629. {
  630. //deployJava.browserName='?';
  631. //deployJava.browserName2='unknown';
  632. deployJava.browserName='MSIE';
  633. deployJava.browserName2='MSIE';
  634. }
  635. if(deployJava.debug)
  636. {
  637. alert('Detected browser name:'+deployJava.browserName+', '+deployJava.browserName2);
  638. }
  639. }
  640. return deployJava.browserName;
  641. }
  642. ,testUsingActiveX:function(version)
  643. {
  644. var objectName='JavaWebStart.isInstalled.'+version+'.0';
  645. if(!ActiveXObject)
  646. {
  647. if(deployJava.debug)
  648. {
  649. alert('Browser claims to be IE, but no ActiveXObject object?');
  650. }
  651. return false;
  652. }
  653. try
  654. {
  655. return(new ActiveXObject(objectName)!=null);
  656. }
  657. catch(exception)
  658. {
  659. return false;
  660. }
  661. }
  662. ,testForMSVM:function()
  663. {
  664. var clsid='{08B0E5C0-4FCB-11CF-AAA5-00401C608500}';
  665. if(typeof oClientCaps!='undefined')
  666. {
  667. var v=oClientCaps.getComponentVersion(clsid,"ComponentID");
  668. if((v=='')||(v=='5,0,5000,0'))
  669. {
  670. return false;
  671. }
  672. else
  673. {
  674. return true;
  675. }
  676. }
  677. else
  678. {
  679. return false;
  680. }
  681. }
  682. ,testUsingMimeTypes:function(version)
  683. {
  684. if(!navigator.mimeTypes)
  685. {
  686. if(deployJava.debug)
  687. {
  688. alert('Browser claims to be Netscape family, but no mimeTypes[] array?');
  689. }
  690. return false;
  691. }
  692. for(var i=0;i<navigator.mimeTypes.length;++i)
  693. {
  694. s=navigator.mimeTypes[i].type;
  695. var m=s.match(/^application\/x-java-applet\x3Bversion=(1\.8|1\.7|1\.6|1\.5|1\.4\.2)$/);
  696. if(m!=null)
  697. {
  698. if(deployJava.compareVersions(m[1],version))
  699. {
  700. return true;
  701. }
  702. }
  703. }
  704. return false;
  705. }
  706. ,testUsingPluginsArray:function(version)
  707. {
  708. if((!navigator.plugins)||(!navigator.plugins.length))
  709. {
  710. return false;
  711. }
  712. var platform=navigator.platform.toLowerCase();
  713. for(var i=0;i<navigator.plugins.length;++i)
  714. {
  715. s=navigator.plugins[i].description;
  716. if(s.search(/^Java Switchable Plug-in (Cocoa)/)!=-1)
  717. {
  718. if(deployJava.compareVersions("1.5.0",version))
  719. {
  720. return true;
  721. }
  722. }
  723. else if(s.search(/^Java/)!=-1)
  724. {
  725. if(platform.indexOf('win')!=-1)
  726. {
  727. if(deployJava.compareVersions("1.5.0",version)||deployJava.compareVersions("1.6.0",version))
  728. {
  729. return true;
  730. }
  731. }
  732. }
  733. }
  734. if(deployJava.compareVersions("1.5.0",version))
  735. {
  736. return true;
  737. }
  738. return false;
  739. }
  740. ,IEInstall:function()
  741. {
  742. location.href=deployJava.getJavaURL+
  743. ((deployJava.returnPage!=null)?('&returnPage='+deployJava.returnPage):'')+
  744. ((deployJava.locale!=null)?('&locale='+deployJava.locale):'')+
  745. ((deployJava.brand!=null)?('&brand='+deployJava.brand):'')+
  746. ((deployJava.installType!=null)?('&type='+deployJava.installType):'');
  747. return false;
  748. }
  749. ,done:function(name,result)
  750. {
  751. }
  752. ,FFInstall:function()
  753. {
  754. location.href=deployJava.getJavaURL+
  755. ((deployJava.returnPage!=null)?('&returnPage='+deployJava.returnPage):'')+
  756. ((deployJava.locale!=null)?('&locale='+deployJava.locale):'')+
  757. ((deployJava.brand!=null)?('&brand='+deployJava.brand):'')+
  758. ((deployJava.installType!=null)?('&type='+deployJava.installType):'');
  759. return false;
  760. }
  761. ,compareVersions:function(installed,required)
  762. {
  763. var a=installed.split('.');
  764. var b=required.split('.');
  765. for(var i=0;i<a.length;++i)
  766. {
  767. a[i]=Number(a[i]);
  768. }
  769. for(var i=0;i<b.length;++i)
  770. {
  771. b[i]=Number(b[i]);
  772. }
  773. if(a.length==2)
  774. {
  775. a[2]=0;
  776. }
  777. if(a[0]>b[0])return true;
  778. if(a[0]<b[0])return false;
  779. if(a[1]>b[1])return true;
  780. if(a[1]<b[1])return false;
  781. if(a[2]>b[2])return true;
  782. if(a[2]<b[2])return false;
  783. return true;
  784. }
  785. ,enableAlerts:function()
  786. {
  787. deployJava.browserName=null;
  788. deployJava.debug=true;
  789. }
  790. ,poll:function()
  791. {
  792. deployJava.refresh();
  793. var postInstallJREList=deployJava.getJREs();
  794. if((deployJava.preInstallJREList.length==0)&&(postInstallJREList.length!=0))
  795. {
  796. clearInterval(deployJava.myInterval);
  797. if(deployJava.returnPage!=null)
  798. {
  799. location.href=deployJava.returnPage;
  800. };
  801. }
  802. if((deployJava.preInstallJREList.length!=0)&&(postInstallJREList.length!=0)&&(deployJava.preInstallJREList[0]!=postInstallJREList[0]))
  803. {
  804. clearInterval(deployJava.myInterval);
  805. if(deployJava.returnPage!=null)
  806. {
  807. location.href=deployJava.returnPage;
  808. }
  809. }
  810. }
  811. ,writePluginTag:function()
  812. {
  813. var browser=deployJava.getBrowser();
  814. if(browser=='MSIE')
  815. {
  816. document.write('<'+'object classid="clsid:CAFEEFAC-DEC7-0000-0000-ABCDEFFEDCBA" '+'id="deployJavaPlugin" width="0" height="0">'+'<'+'/'+'object'+'>');
  817. }
  818. else if(browser=='Netscape Family'&&deployJava.allowPlugin())
  819. {
  820. deployJava.writeEmbedTag();
  821. }
  822. }
  823. ,refresh:function()
  824. {
  825. navigator.plugins.refresh(false);
  826. var browser=deployJava.getBrowser();
  827. if(browser=='Netscape Family'&&deployJava.allowPlugin())
  828. {
  829. var plugin=document.getElementById('deployJavaPlugin');
  830. if(plugin==null)
  831. {
  832. deployJava.writeEmbedTag();
  833. }
  834. }
  835. }
  836. ,writeEmbedTag:function()
  837. {
  838. var written=false;
  839. if(navigator.mimeTypes!=null)
  840. {
  841. for(var i=0;i<navigator.mimeTypes.length;i++)
  842. {
  843. if(navigator.mimeTypes[i].type==deployJava.mimeType)
  844. {
  845. if(navigator.mimeTypes[i].enabledPlugin)
  846. {
  847. document.write('<'+'embed id="deployJavaPlugin" type="'+
  848. deployJava.mimeType+'" hidden="true" />');
  849. written=true;
  850. }
  851. }
  852. }
  853. if(!written)for(var i=0;
  854. i<navigator.mimeTypes.length;
  855. i++)
  856. {
  857. if(navigator.mimeTypes[i].type==deployJava.oldMimeType)
  858. {
  859. if(navigator.mimeTypes[i].enabledPlugin)
  860. {
  861. document.write('<'+'embed id="deployJavaPlugin" type="'+
  862. deployJava.oldMimeType+'" hidden="true" />');
  863. }
  864. }
  865. }
  866. }
  867. }
  868. ,do_initialize:function()
  869. {
  870. deployJava.writePluginTag();
  871. if(deployJava.locale==null)
  872. {
  873. var loc=null;
  874. if(loc==null)try
  875. {
  876. loc=navigator.userLanguage;
  877. }
  878. catch(err)
  879. {
  880. }
  881. if(loc==null)try
  882. {
  883. loc=navigator.systemLanguage;
  884. }
  885. catch(err)
  886. {
  887. }
  888. if(loc==null)try
  889. {
  890. loc=navigator.language;
  891. }
  892. catch(err)
  893. {
  894. }
  895. if(loc!=null)
  896. {
  897. loc.replace("-","_");
  898. deployJava.locale=loc;
  899. }
  900. }
  901. }
  902. };
  903. if(deployJava.browserName==null)
  904. {
  905. var browser=navigator.userAgent.toLowerCase();
  906. if(deployJava.debug)
  907. {
  908. alert('userAgent -> '+browser);
  909. }
  910. if(browser.indexOf('msie')!=-1)
  911. {
  912. deployJava.browserName='MSIE';
  913. deployJava.browserName2='MSIE';
  914. }
  915. else if(browser.indexOf('trident')!=-1)
  916. {
  917. deployJava.browserName='MSIE';
  918. deployJava.browserName2='MSIE';
  919. }
  920. else if(browser.indexOf('firefox')!=-1)
  921. {
  922. deployJava.browserName='Netscape Family';
  923. deployJava.browserName2='Firefox';
  924. }
  925. else if(browser.indexOf('chrome')!=-1)
  926. {
  927. deployJava.browserName='Netscape Family';
  928. deployJava.browserName2='Chrome';
  929. }
  930. else if(browser.indexOf('safari')!=-1)
  931. {
  932. deployJava.browserName='Netscape Family';
  933. deployJava.browserName2='Safari';
  934. }
  935. else if(browser.indexOf('mozilla')!=-1)
  936. {
  937. deployJava.browserName='Netscape Family';
  938. deployJava.browserName2='Other';
  939. }
  940. else if(browser.indexOf('opera')!=-1)
  941. {
  942. deployJava.browserName='Netscape Family';
  943. deployJava.browserName2='Opera';
  944. }
  945. else
  946. {
  947. //deployJava.browserName='?';
  948. //deployJava.browserName2='unknown';
  949. deployJava.browserName='MSIE';
  950. deployJava.browserName2='MSIE';
  951. }
  952. if(deployJava.debug)
  953. {
  954. alert('Detected browser name:'+deployJava.browserName+', '+deployJava.browserName2);
  955. }
  956. }
  957. var browser = deployJava.browserName2;
  958. if(browser == "MSIE"){
  959. }else{
  960. deployJava.do_initialize();
  961. }