deployJava.js 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357
  1. /*
  2. * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
  3. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * - Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. *
  12. * - Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * - Neither the name of Oracle nor the names of its
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  21. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  22. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  24. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  27. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  28. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  29. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  30. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. /*
  33. * deployJava.js
  34. *
  35. * This file is part of the Deployment Toolkit. It provides functions for web
  36. * pages to detect the presence of a JRE, install the latest JRE, and easily run
  37. * applets or Web Start programs. More Information on usage of the
  38. * Deployment Toolkit can be found in the Deployment Guide at:
  39. * http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/index.html
  40. *
  41. * The "live" copy of this file may be found at :
  42. * http://java.com/js/deployJava.js.
  43. * For web pages provisioned using https, you may want to access the copy at:
  44. * https://java.com/js/deployJava.js.
  45. *
  46. * You are encouraged to link directly to the live copies.
  47. * The above files are stripped of comments and whitespace for performance,
  48. * You can access this file w/o the whitespace and comments removed at:
  49. * http://java.com/js/deployJava.txt.
  50. *
  51. */
  52. /* The following regular expression is used as the base for the parsing
  53. * of the version string. The version string could be either in the old format
  54. * (1.7.0_65, 1.7.0, 1.7) or in the new format (9.1.2.3, 9.1.2, 9.1, 9)
  55. * and must include only VNUM parts of the version string (the full
  56. * version string format is $VNUM(-$PRE)?(\+$BUILD)?(-$OPT)?, see JEP 223 for more details)
  57. *
  58. * ^ - Beginning of the string
  59. * ( - Capturing group 1
  60. * \\d+ - Match any digit one or more times
  61. * ) - Match once
  62. * (?: - Non capturing group
  63. * \\. - Match '.' character
  64. * ( - Capturing group 2
  65. * \\d+ - Match any digit one or more times
  66. * ) - Match once
  67. * (?: - Non capturing group
  68. * \\. - Match '.' character
  69. * ( - Capturing group 3
  70. * \\d+ - Match any digit one or more times
  71. * ) - Match once
  72. * (?: - Non capturing group
  73. * [_\\.] - Math '_' (old version format) or '.' (new version format)
  74. * ( - Capturing group 4
  75. * \\d+ - Match any digit one or more times
  76. * ) - Match once
  77. * )? - Match zero or one time
  78. * )? - Match zero or one time
  79. * )? - Match zero or one time
  80. *
  81. *
  82. *
  83. */
  84. var version_regex_base = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:[_\\.](\\d+))?)?)?";
  85. /*
  86. * version_regex_base - see version_regex_base comment above
  87. * $ - End of the string
  88. *
  89. */
  90. var version_regex_strict = version_regex_base + "$";
  91. /*
  92. * version_regex_base - see version_regex_base comment above
  93. * ( - Capturing group 5
  94. * \\* - Match '*'
  95. * | - OR
  96. * \\+ - Match '+'
  97. * )? - Match zero or one time
  98. * $ - End of string
  99. *
  100. */
  101. var version_regex_with_family_modifier = version_regex_base + "(\\*|\\+)?$";
  102. var deployJava = function() {
  103. /** HTML attribute filter implementation */
  104. var hattrs = {
  105. core: [ 'id', 'class', 'title', 'style' ],
  106. i18n: [ 'lang', 'dir' ],
  107. events: [ 'onclick', 'ondblclick', 'onmousedown', 'onmouseup',
  108. 'onmouseover', 'onmousemove', 'onmouseout', 'onkeypress',
  109. 'onkeydown', 'onkeyup' ],
  110. applet: [ 'codebase', 'code', 'name', 'archive', 'object',
  111. 'width', 'height', 'alt', 'align', 'hspace', 'vspace' ],
  112. object: [ 'classid', 'codebase', 'codetype', 'data', 'type',
  113. 'archive', 'declare', 'standby', 'height', 'width', 'usemap',
  114. 'name', 'tabindex', 'align', 'border', 'hspace', 'vspace' ]
  115. };
  116. var object_valid_attrs = hattrs.object.concat(hattrs.core, hattrs.i18n,
  117. hattrs.events);
  118. var applet_valid_attrs = hattrs.applet.concat(hattrs.core);
  119. // generic log function, use console.log unless it isn't available
  120. // then revert to alert()
  121. function log(message) {
  122. if ( ! rv.debug ) {return};
  123. if (console.log) {
  124. console.log(message);
  125. } else {
  126. alert(message);
  127. }
  128. }
  129. //checks where given version string matches query
  130. //
  131. //NB: assume format is correct. Can add format check later if needed
  132. // from dtjava.js
  133. function versionCheckEx(query, version) {
  134. if (query == null || query.length == 0) return true;
  135. var c = query.charAt(query.length - 1);
  136. //if it is not explicit pattern but does not have update version then need to append *
  137. if (c != '+' && c != '*' && (query.indexOf('_') != -1 && c != '_')) {
  138. query = query + "*";
  139. c = '*';
  140. }
  141. query = query.substring(0, query.length - 1);
  142. //if query ends with ".", "_" then we want to strip it to allow match of "1.6.*" to shorter form such as "1.6"
  143. //TODO: add support for match of "1.7.0*" to "1.7"?
  144. if (query.length > 0) {
  145. var z = query.charAt(query.length - 1);
  146. if (z == '.' || z == '_') {
  147. query = query.substring(0, query.length - 1);
  148. }
  149. }
  150. if (c == '*') {
  151. //it is match if version starts from it
  152. return (version.indexOf(query) == 0);
  153. } else if (c == '+') {
  154. //match if query string is lexicographically smaller
  155. return query <= version;
  156. }
  157. return false;
  158. }
  159. function getWebStartLaunchIconURL() {
  160. var imageUrl = '//java.com/js/webstart.png';
  161. try {
  162. // for http/https; use protocol less url; use http for all other protocol
  163. return document.location.protocol.indexOf('http') != -1 ?
  164. imageUrl : 'http:' + imageUrl;
  165. } catch (err) {
  166. return 'http:' + imageUrl;
  167. }
  168. }
  169. // GetJava page
  170. function constructGetJavaURL(query) {
  171. var getJavaURL = 'http://java.com/dt-redirect';
  172. if (query == null || query.length == 0) return getJavaURL;
  173. if(query.charAt(0) == '&')
  174. {
  175. query = query.substring(1, query.length);
  176. }
  177. return getJavaURL + '?'+ query;
  178. }
  179. function arHas(ar, attr) {
  180. var len = ar.length;
  181. for (var i = 0; i < len; i++) {
  182. if (ar[i] === attr) return true;
  183. }
  184. return false;
  185. }
  186. function isValidAppletAttr(attr) {
  187. return arHas(applet_valid_attrs, attr.toLowerCase());
  188. }
  189. function isValidObjectAttr(attr) {
  190. return arHas(object_valid_attrs, attr.toLowerCase());
  191. }
  192. /**
  193. * returns true if we can enable DT plugin auto-install without chance of
  194. * deadlock on cert mismatch dialog
  195. *
  196. * requestedJREVersion param is optional - if null, it will be
  197. * treated as installing any JRE version
  198. *
  199. * DT plugin for 6uX only knows about JRE installer signed by SUN cert.
  200. * If it encounter Oracle signed JRE installer, it will have chance of
  201. * deadlock when running with IE. This function is to guard against this.
  202. */
  203. function enableWithoutCertMisMatchWorkaround(requestedJREVersion) {
  204. // Non-IE browser are okay
  205. if ('MSIE' != deployJava.browserName) return true;
  206. // if DT plugin is 10.0.0 or above, return true
  207. // This is because they are aware of both SUN and Oracle signature and
  208. // will not show cert mismatch dialog that might cause deadlock
  209. if (deployJava.compareVersionToPattern(deployJava.getPlugin().version,
  210. ["10", "0", "0"], false, true)) {
  211. return true;
  212. }
  213. // If we got there, DT plugin is 6uX
  214. if (requestedJREVersion == null) {
  215. // if requestedJREVersion is not defined - it means ANY.
  216. // can not guarantee it is safe to install ANY version because 6uX
  217. // DT does not know about Oracle certificates and may deadlock
  218. return false;
  219. }
  220. // 6u32 or earlier JRE installer used Sun certificate
  221. // 6u33+ uses Oracle's certificate
  222. // DT in JRE6 does not know about Oracle certificate => can only
  223. // install 6u32 or earlier without risk of deadlock
  224. return !versionCheckEx("1.6.0_33+", requestedJREVersion);
  225. }
  226. /* HTML attribute filters */
  227. var rv = {
  228. debug: null,
  229. /* version of deployJava.js */
  230. version: "20120801",
  231. firefoxJavaVersion: null,
  232. myInterval: null,
  233. preInstallJREList: null,
  234. returnPage: null,
  235. brand: null,
  236. locale: null,
  237. installType: null,
  238. EAInstallEnabled: false,
  239. EarlyAccessURL: null,
  240. // mime-type of the DeployToolkit plugin object
  241. oldMimeType: 'application/npruntime-scriptable-plugin;DeploymentToolkit',
  242. mimeType: 'application/java-deployment-toolkit',
  243. /* location of the Java Web Start launch button graphic is right next to
  244. * deployJava.js at:
  245. * http://java.com/js/webstart.png
  246. *
  247. * Use protocol less url here for http/https support
  248. */
  249. launchButtonPNG: getWebStartLaunchIconURL(),
  250. browserName: null,
  251. browserName2: null,
  252. /**
  253. * Returns an array of currently-installed JRE version strings.
  254. * Version strings are of the form #.#[.#[_#]], with the function returning
  255. * as much version information as it can determine, from just family
  256. * versions ("1.4.2", "1.5") through the full version ("1.5.0_06").
  257. *
  258. * Detection is done on a best-effort basis. Under some circumstances
  259. * only the highest installed JRE version will be detected, and
  260. * JREs older than 1.4.2 will not always be detected.
  261. */
  262. getJREs: function() {
  263. var list = new Array();
  264. if (this.isPluginInstalled()) {
  265. var plugin = this.getPlugin();
  266. var VMs = plugin.jvms;
  267. for (var i = 0; i < VMs.getLength(); i++) {
  268. list[i] = VMs.get(i).version;
  269. }
  270. } else {
  271. var browser = this.getBrowser();
  272. if (browser == 'MSIE') {
  273. if (this.testUsingActiveX('1.7.0')) {
  274. list[0] = '1.7.0';
  275. } else if (this.testUsingActiveX('1.6.0')) {
  276. list[0] = '1.6.0';
  277. } else if (this.testUsingActiveX('1.5.0')) {
  278. list[0] = '1.5.0';
  279. } else if (this.testUsingActiveX('1.4.2')) {
  280. list[0] = '1.4.2';
  281. } else if (this.testForMSVM()) {
  282. list[0] = '1.1';
  283. }
  284. } else if (browser == 'Netscape Family') {
  285. this.getJPIVersionUsingMimeType();
  286. if (this.firefoxJavaVersion != null) {
  287. list[0] = this.firefoxJavaVersion;
  288. } else if (this.testUsingMimeTypes('1.7')) {
  289. list[0] = '1.7.0';
  290. } else if (this.testUsingMimeTypes('1.6')) {
  291. list[0] = '1.6.0';
  292. } else if (this.testUsingMimeTypes('1.5')) {
  293. list[0] = '1.5.0';
  294. } else if (this.testUsingMimeTypes('1.4.2')) {
  295. list[0] = '1.4.2';
  296. } else if (this.browserName2 == 'Safari') {
  297. if (this.testUsingPluginsArray('1.7.0')) {
  298. list[0] = '1.7.0';
  299. } else if (this.testUsingPluginsArray('1.6')) {
  300. list[0] = '1.6.0';
  301. } else if (this.testUsingPluginsArray('1.5')) {
  302. list[0] = '1.5.0';
  303. } else if (this.testUsingPluginsArray('1.4.2')) {
  304. list[0] = '1.4.2';
  305. }
  306. }
  307. }
  308. }
  309. if (this.debug) {
  310. for (var i = 0; i < list.length; ++i) {
  311. log('[getJREs()] We claim to have detected Java SE ' + list[i]);
  312. }
  313. }
  314. return list;
  315. },
  316. /**
  317. * Triggers a JRE installation. The exact effect of triggering an
  318. * installation varies based on platform, browser, and if the
  319. * Deployment Toolkit plugin is installed.
  320. *
  321. * The requestVersion string is of the form #[.#[.#[_#]]][+|*],
  322. * which includes strings such as "1.4", "1.5.0*", and "1.6.0_02+".
  323. * A star (*) means "any version starting within this family" and
  324. * a plus (+) means "any version greater or equal to this".
  325. * "1.5.0*" * matches 1.5.0_06 but not 1.6.0_01, whereas
  326. * "1.5.0+" matches both.
  327. *
  328. * installCallback is an optional argument which holds a reference
  329. * to a javascript callback function for reporting install status.
  330. *
  331. * If the Deployment Toolkit plugin is not present, this will just call
  332. * this.installLatestJRE().
  333. */
  334. installJRE: function(requestVersion, installCallback) {
  335. var ret = false;
  336. if (this.isPluginInstalled() &&
  337. this.isAutoInstallEnabled(requestVersion)) {
  338. var installSucceeded = false;
  339. if (this.isCallbackSupported()) {
  340. installSucceeded =
  341. this.getPlugin().installJRE(requestVersion, installCallback);
  342. } else {
  343. installSucceeded = this.getPlugin().installJRE(requestVersion);
  344. }
  345. if (installSucceeded) {
  346. this.refresh();
  347. if (this.returnPage != null) {
  348. document.location = this.returnPage;
  349. }
  350. }
  351. return installSucceeded;
  352. } else {
  353. return this.installLatestJRE();
  354. }
  355. },
  356. /**
  357. * returns true if jre auto install for the requestedJREVersion is enabled
  358. * for the local system; false otherwise
  359. *
  360. * requestedJREVersion param is optional - if not specified, it will be
  361. * treated as installing any JRE version
  362. *
  363. * DT plugin for 6uX only knows about JRE installer signed by SUN cert.
  364. * If it encounter Oracle signed JRE installer, it will have chance of
  365. * deadlock when running with IE. This function is to guard against this.
  366. */
  367. isAutoInstallEnabled: function(requestedJREVersion) {
  368. // if no DT plugin, return false
  369. if (!this.isPluginInstalled()) return false;
  370. if (typeof requestedJREVersion == 'undefined') {
  371. requestedJREVersion = null;
  372. }
  373. return enableWithoutCertMisMatchWorkaround(requestedJREVersion);
  374. },
  375. /**
  376. * returns true if jre install callback is supported
  377. * callback support is added since dt plugin version 10.2.0 or above
  378. */
  379. isCallbackSupported: function() {
  380. return this.isPluginInstalled() &&
  381. this.compareVersionToPattern(this.getPlugin().version,
  382. ["10", "2", "0"], false, true);
  383. },
  384. /**
  385. * Triggers a JRE installation. The exact effect of triggering an
  386. * installation varies based on platform, browser, and if the
  387. * Deployment Toolkit plugin is installed.
  388. *
  389. * In the simplest case, the browser window will be redirected to the
  390. * java.com JRE installation page, and (if possible) a redirect back to
  391. * the current URL upon successful installation. The return redirect is
  392. * not always possible, as the JRE installation may require the browser to
  393. * be restarted.
  394. *
  395. * installCallback is an optional argument which holds a reference
  396. * to a javascript callback function for reporting install status.
  397. *
  398. * In the best case (when the Deployment Toolkit plugin is present), this
  399. * function will immediately cause a progress dialog to be displayed
  400. * as the JRE is downloaded and installed.
  401. */
  402. installLatestJRE: function(installCallback) {
  403. if (this.isPluginInstalled() && this.isAutoInstallEnabled()) {
  404. var installSucceeded = false;
  405. if (this.isCallbackSupported()) {
  406. installSucceeded = this.getPlugin().installLatestJRE(installCallback);
  407. } else {
  408. installSucceeded = this.getPlugin().installLatestJRE();
  409. }
  410. if (installSucceeded) {
  411. this.refresh();
  412. if (this.returnPage != null) {
  413. document.location = this.returnPage;
  414. }
  415. }
  416. return installSucceeded;
  417. } else {
  418. var browser = this.getBrowser();
  419. var platform = navigator.platform.toLowerCase();
  420. if ((this.EAInstallEnabled == 'true') &&
  421. (platform.indexOf('win') != -1) &&
  422. (this.EarlyAccessURL != null)) {
  423. this.preInstallJREList = this.getJREs();
  424. if (this.returnPage != null) {
  425. this.myInterval =
  426. setInterval("deployJava.poll()", 3000);
  427. }
  428. location.href = this.EarlyAccessURL;
  429. // we have to return false although there may be an install
  430. // in progress now, when complete it may go to return page
  431. return false;
  432. } else {
  433. if (browser == 'MSIE') {
  434. return this.IEInstall();
  435. } else if ((browser == 'Netscape Family') &&
  436. (platform.indexOf('win32') != -1)) {
  437. return this.FFInstall();
  438. } else {
  439. location.href = constructGetJavaURL(
  440. ((this.returnPage != null) ?
  441. ('&returnPage=' + this.returnPage) : '') +
  442. ((this.locale != null) ?
  443. ('&locale=' + this.locale) : '') +
  444. ((this.brand != null) ?
  445. ('&brand=' + this.brand) : ''));
  446. }
  447. // we have to return false although there may be an install
  448. // in progress now, when complete it may go to return page
  449. return false;
  450. }
  451. }
  452. },
  453. /**
  454. * Ensures that an appropriate JRE is installed and then runs an applet.
  455. * minimumVersion is of the form #[.#[.#[_#]]], and is the minimum
  456. * JRE version necessary to run this applet. minimumVersion is optional,
  457. * defaulting to the value "1.1" (which matches any JRE).
  458. * If an equal or greater JRE is detected, runApplet() will call
  459. * writeAppletTag(attributes, parameters) to output the applet tag,
  460. * otherwise it will call installJRE(minimumVersion + '+').
  461. *
  462. * After installJRE() is called, the script will attempt to detect that the
  463. * JRE installation has completed and begin running the applet, but there
  464. * are circumstances (such as when the JRE installation requires a browser
  465. * restart) when this cannot be fulfilled.
  466. *
  467. * As with writeAppletTag(), this function should only be called prior to
  468. * the web page being completely rendered. Note that version wildcards
  469. * (star (*) and plus (+)) are not supported, and including them in the
  470. * minimumVersion will result in an error message.
  471. */
  472. runApplet: function(attributes, parameters, minimumVersion) {
  473. if (minimumVersion == 'undefined' || minimumVersion == null) {
  474. minimumVersion = '1.1';
  475. }
  476. var matchData = minimumVersion.match(version_regex_strict);
  477. if (this.returnPage == null) {
  478. // if there is an install, come back here and run the applet
  479. this.returnPage = document.location;
  480. }
  481. if (matchData != null) {
  482. var browser = this.getBrowser();
  483. if (browser != '?') {
  484. if (this.versionCheck(minimumVersion + '+')) {
  485. this.writeAppletTag(attributes, parameters);
  486. } else if (this.installJRE(minimumVersion + '+')) {
  487. // after successful install we need to refresh page to pick
  488. // pick up new plugin
  489. this.refresh();
  490. location.href = document.location;
  491. this.writeAppletTag(attributes, parameters);
  492. }
  493. } else {
  494. // for unknown or Safari - just try to show applet
  495. this.writeAppletTag(attributes, parameters);
  496. }
  497. } else {
  498. log('[runApplet()] Invalid minimumVersion argument to runApplet():' +
  499. minimumVersion);
  500. }
  501. },
  502. /**
  503. * Outputs an applet tag with the specified attributes and parameters, where
  504. * both attributes and parameters are associative arrays. Each key/value
  505. * pair in attributes becomes an attribute of the applet tag itself, while
  506. * key/value pairs in parameters become <PARAM> tags. No version checking
  507. * or other special behaviors are performed; the tag is simply written to
  508. * the page using document.writeln().
  509. *
  510. * As document.writeln() is generally only safe to use while the page is
  511. * being rendered, you should never call this function after the page
  512. * has been completed.
  513. */
  514. writeAppletTag: function(attributes, parameters) {
  515. var startApplet = '<' + 'applet ';
  516. var params = '';
  517. var endApplet = '<' + '/' + 'applet' + '>';
  518. var addCodeAttribute = true;
  519. if (null == parameters || typeof parameters != 'object') {
  520. parameters = new Object();
  521. }
  522. for (var attribute in attributes) {
  523. if (! isValidAppletAttr(attribute)) {
  524. parameters[attribute] = attributes[attribute];
  525. } else {
  526. startApplet += (' ' +attribute+ '="' +attributes[attribute] + '"');
  527. if (attribute == 'code') {
  528. addCodeAttribute = false;
  529. }
  530. }
  531. }
  532. var codebaseParam = false;
  533. for (var parameter in parameters) {
  534. if (parameter == 'codebase_lookup') {
  535. codebaseParam = true;
  536. }
  537. // Originally, parameter 'object' was used for serialized
  538. // applets, later, to avoid confusion with object tag in IE
  539. // the 'java_object' was added. Plugin supports both.
  540. if (parameter == 'object' || parameter == 'java_object' ||
  541. parameter == 'java_code' ) {
  542. addCodeAttribute = false;
  543. }
  544. params += '<param name="' + parameter + '" value="' +
  545. parameters[parameter] + '"/>';
  546. }
  547. if (!codebaseParam) {
  548. params += '<param name="codebase_lookup" value="false"/>';
  549. }
  550. if (addCodeAttribute) {
  551. startApplet += (' code="dummy"');
  552. }
  553. startApplet += '>';
  554. document.write(startApplet + '\n' + params + '\n' + endApplet);
  555. },
  556. /**
  557. * Returns true if there is a matching JRE version currently installed
  558. * (among those detected by getJREs()). The versionPattern string is
  559. * of the form #[.#[.#[_#]]][+|*], which includes strings such as "1.4",
  560. * "1.5.0*", and "1.6.0_02+".
  561. * A star (*) means "any version within this family" and a plus (+) means
  562. * "any version greater or equal to the specified version". "1.5.0*"
  563. * matches 1.5.0_06 but not 1.6.0_01, whereas "1.5.0+" matches both.
  564. *
  565. * If the versionPattern does not include all four version components
  566. * but does not end with a star or plus, it will be treated as if it
  567. * ended with a star. "1.5" is exactly equivalent to "1.5*", and will
  568. * match any version number beginning with "1.5".
  569. *
  570. * If getJREs() is unable to detect the precise version number, a match
  571. * could be ambiguous. For example if getJREs() detects "1.5", there is
  572. * no way to know whether the JRE matches "1.5.0_06+". versionCheck()
  573. * compares only as much of the version information as could be detected,
  574. * so versionCheck("1.5.0_06+") would return true in in this case.
  575. *
  576. * Invalid versionPattern will result in a JavaScript error alert.
  577. * versionPatterns which are valid but do not match any existing JRE
  578. * release (e.g. "32.65+") will always return false.
  579. */
  580. versionCheck: function(versionPattern)
  581. {
  582. var index = 0;
  583. var matchData = versionPattern.match(version_regex_with_family_modifier);
  584. if (matchData != null) {
  585. // default is exact version match
  586. // examples:
  587. // local machine has 1.7.0_04 only installed
  588. // exact match request is "1.7.0_05": return false
  589. // family match request is "1.7.0*": return true
  590. // minimum match request is "1.6+": return true
  591. var familyMatch = false;
  592. var minMatch = false;
  593. var patternArray = new Array();
  594. for (var i = 1; i < matchData.length; ++i) {
  595. // browser dependency here.
  596. // Fx sets 'undefined', IE sets '' string for unmatched groups
  597. if ((typeof matchData[i] == 'string') && (matchData[i] != '')) {
  598. patternArray[index] = matchData[i];
  599. index++;
  600. }
  601. }
  602. if (patternArray[patternArray.length-1] == '+') {
  603. // + specified in request - doing a minimum match
  604. minMatch = true;
  605. familyMatch = false;
  606. patternArray.length--;
  607. } else if (patternArray[patternArray.length-1] == '*') {
  608. // * specified in request - doing a family match
  609. minMatch = false;
  610. familyMatch = true;
  611. patternArray.length--;
  612. } else if (patternArray.length < 4) {
  613. // versionPattern does not include all four version components
  614. // and does not end with a star or plus, it will be treated as
  615. // if it ended with a star. (family match)
  616. minMatch = false;
  617. familyMatch = true;
  618. }
  619. var list = this.getJREs();
  620. for (var i = 0; i < list.length; ++i) {
  621. if (this.compareVersionToPattern(list[i], patternArray,
  622. familyMatch, minMatch)) {
  623. return true;
  624. }
  625. }
  626. return false;
  627. } else {
  628. var msg = 'Invalid versionPattern passed to versionCheck: ' +
  629. versionPattern;
  630. log('[versionCheck()] ' + msg);
  631. alert(msg);
  632. return false;
  633. }
  634. },
  635. /**
  636. * Returns true if an installation of Java Web Start of the specified
  637. * minimumVersion can be detected. minimumVersion is optional, and
  638. * if not specified, '1.4.2' will be used.
  639. * (Versions earlier than 1.4.2 may not be detected.)
  640. */
  641. isWebStartInstalled: function(minimumVersion) {
  642. var browser = this.getBrowser();
  643. if (browser == '?') {
  644. // we really don't know - better to try to use it than reinstall
  645. return true;
  646. }
  647. if (minimumVersion == 'undefined' || minimumVersion == null) {
  648. minimumVersion = '1.4.2';
  649. }
  650. var retval = false;
  651. var matchData = minimumVersion.match(version_regex_strict);
  652. if (matchData != null) {
  653. retval = this.versionCheck(minimumVersion + '+');
  654. } else {
  655. log('[isWebStartInstaller()] Invalid minimumVersion argument to isWebStartInstalled(): ' + minimumVersion);
  656. retval = this.versionCheck('1.4.2+');
  657. }
  658. return retval;
  659. },
  660. // obtain JPI version using navigator.mimeTypes array
  661. // if found, set the version to this.firefoxJavaVersion
  662. getJPIVersionUsingMimeType: function() {
  663. // Walk through the full list of mime types.
  664. for (var i = 0; i < navigator.mimeTypes.length; ++i) {
  665. var s = navigator.mimeTypes[i].type;
  666. // The jpi-version is the plug-in version. This is the best
  667. // version to use.
  668. var m = s.match(/^application\/x-java-applet;jpi-version=(.*)$/);
  669. if (m != null) {
  670. this.firefoxJavaVersion = m[1];
  671. // Opera puts the latest sun JRE last not first
  672. if ('Opera' != this.browserName2) {
  673. break;
  674. }
  675. }
  676. }
  677. },
  678. // launch the specified JNLP application using the passed in jnlp file
  679. // the jnlp file does not need to have a codebase
  680. // this requires JRE 7 or above to work
  681. // if machine has no JRE 7 or above, we will try to auto-install and then launch
  682. // (function will return false if JRE auto-install failed)
  683. launchWebStartApplication: function(jnlp) {
  684. var uaString = navigator.userAgent.toLowerCase();
  685. this.getJPIVersionUsingMimeType();
  686. // make sure we are JRE 7 or above
  687. if (this.isWebStartInstalled('1.7.0') == false) {
  688. // perform latest JRE auto-install
  689. if ((this.installJRE('1.7.0+') == false) ||
  690. ((this.isWebStartInstalled('1.7.0') == false))) {
  691. return false;
  692. }
  693. }
  694. var jnlpDocbase = null;
  695. // use document.documentURI for docbase
  696. if (document.documentURI) {
  697. jnlpDocbase = document.documentURI;
  698. }
  699. // fallback to document.URL if documentURI not available
  700. if (jnlpDocbase == null) {
  701. jnlpDocbase = document.URL;
  702. }
  703. var browser = this.getBrowser();
  704. var launchTag;
  705. if (browser == 'MSIE') {
  706. launchTag = '<' +
  707. 'object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" ' +
  708. 'width="0" height="0">' +
  709. '<' + 'PARAM name="launchjnlp" value="' + jnlp + '"' + '>' +
  710. '<' + 'PARAM name="docbase" value="' + encodeURIComponent(jnlpDocbase) + '"' + '>' +
  711. '<' + '/' + 'object' + '>';
  712. } else if (browser == 'Netscape Family') {
  713. launchTag = '<' +
  714. 'embed type="application/x-java-applet;jpi-version=' +
  715. this.firefoxJavaVersion + '" ' +
  716. 'width="0" height="0" ' +
  717. 'launchjnlp="' + jnlp + '"' +
  718. 'docbase="' + encodeURIComponent(jnlpDocbase) + '"' +
  719. ' />';
  720. }
  721. if (document.body == 'undefined' || document.body == null) {
  722. document.write(launchTag);
  723. // go back to original page, otherwise current page becomes blank
  724. document.location = jnlpDocbase;
  725. } else {
  726. var divTag = document.createElement("div");
  727. divTag.id = "div1";
  728. divTag.style.position = "relative";
  729. divTag.style.left = "-10000px";
  730. divTag.style.margin = "0px auto";
  731. divTag.className ="dynamicDiv";
  732. divTag.innerHTML = launchTag;
  733. document.body.appendChild(divTag);
  734. }
  735. },
  736. createWebStartLaunchButtonEx: function(jnlp, minimumVersion) {
  737. if (this.returnPage == null) {
  738. // if there is an install, come back and run the jnlp file
  739. this.returnPage = jnlp;
  740. }
  741. var url = 'javascript:deployJava.launchWebStartApplication(\'' + jnlp +
  742. '\');';
  743. document.write('<' + 'a href="' + url +
  744. '" onMouseOver="window.status=\'\'; ' +
  745. 'return true;"><' + 'img ' +
  746. 'src="' + this.launchButtonPNG + '" ' +
  747. 'border="0" /><' + '/' + 'a' + '>');
  748. },
  749. /**
  750. * Outputs a launch button for the specified JNLP URL. When clicked, the
  751. * button will ensure that an appropriate JRE is installed and then launch
  752. * the JNLP application. minimumVersion is of the form #[.#[.#[_#]]], and
  753. * is the minimum JRE version necessary to run this JNLP application.
  754. * minimumVersion is optional, and if it is not specified, '1.4.2'
  755. * will be used.
  756. * If an appropriate JRE or Web Start installation is detected,
  757. * the JNLP application will be launched, otherwise installLatestJRE()
  758. * will be called.
  759. *
  760. * After installLatestJRE() is called, the script will attempt to detect
  761. * that the JRE installation has completed and launch the JNLP application,
  762. * but there are circumstances (such as when the JRE installation
  763. * requires a browser restart) when this cannot be fulfilled.
  764. */
  765. createWebStartLaunchButton: function(jnlp, minimumVersion) {
  766. if (this.returnPage == null) {
  767. // if there is an install, come back and run the jnlp file
  768. this.returnPage = jnlp;
  769. }
  770. var url = 'javascript:' +
  771. 'if (!deployJava.isWebStartInstalled(&quot;' +
  772. minimumVersion + '&quot;)) {' +
  773. 'if (deployJava.installLatestJRE()) {' +
  774. 'if (deployJava.launch(&quot;' + jnlp + '&quot;)) {}' +
  775. '}' +
  776. '} else {' +
  777. 'if (deployJava.launch(&quot;' + jnlp + '&quot;)) {}' +
  778. '}';
  779. document.write('<' + 'a href="' + url +
  780. '" onMouseOver="window.status=\'\'; ' +
  781. 'return true;"><' + 'img ' +
  782. 'src="' + this.launchButtonPNG + '" ' +
  783. 'border="0" /><' + '/' + 'a' + '>');
  784. },
  785. /**
  786. * Launch a JNLP application, (using the plugin if available)
  787. */
  788. launch: function(jnlp) {
  789. /*
  790. * Using the plugin to launch Java Web Start is disabled for the time being
  791. */
  792. document.location=jnlp;
  793. return true;
  794. },
  795. /*
  796. * returns true if the ActiveX or XPI plugin is installed
  797. */
  798. isPluginInstalled: function() {
  799. var plugin = this.getPlugin();
  800. if (plugin && plugin.jvms) {
  801. return true;
  802. } else {
  803. return false;
  804. }
  805. },
  806. /*
  807. * returns true if the plugin is installed and AutoUpdate is enabled
  808. */
  809. isAutoUpdateEnabled: function() {
  810. if (this.isPluginInstalled()) {
  811. return this.getPlugin().isAutoUpdateEnabled();
  812. }
  813. return false;
  814. },
  815. /*
  816. * sets AutoUpdate on if plugin is installed
  817. */
  818. setAutoUpdateEnabled: function() {
  819. if (this.isPluginInstalled()) {
  820. return this.getPlugin().setAutoUpdateEnabled();
  821. }
  822. return false;
  823. },
  824. /*
  825. * sets the preferred install type : null, online, kernel
  826. */
  827. setInstallerType: function(type) {
  828. this.installType = type;
  829. if (this.isPluginInstalled()) {
  830. return this.getPlugin().setInstallerType(type);
  831. }
  832. return false;
  833. },
  834. /*
  835. * sets additional package list - to be used by kernel installer
  836. */
  837. setAdditionalPackages: function(packageList) {
  838. if (this.isPluginInstalled()) {
  839. return this.getPlugin().setAdditionalPackages(
  840. packageList);
  841. }
  842. return false;
  843. },
  844. /*
  845. * sets preference to install Early Access versions if available
  846. */
  847. setEarlyAccess: function(enabled) {
  848. this.EAInstallEnabled = enabled;
  849. },
  850. /*
  851. * Determines if the next generation plugin (Plugin II) is default
  852. */
  853. isPlugin2: function() {
  854. if (this.isPluginInstalled()) {
  855. if (this.versionCheck('1.6.0_10+')) {
  856. try {
  857. return this.getPlugin().isPlugin2();
  858. } catch (err) {
  859. // older plugin w/o isPlugin2() function -
  860. }
  861. }
  862. }
  863. return false;
  864. },
  865. //support native DT plugin?
  866. allowPlugin: function() {
  867. this.getBrowser();
  868. // Safari and Opera browsers find the plugin but it
  869. // doesn't work, so until we can get it to work - don't use it.
  870. var ret = ('Safari' != this.browserName2 &&
  871. 'Opera' != this.browserName2);
  872. return ret;
  873. },
  874. getPlugin: function() {
  875. this.refresh();
  876. var ret = null;
  877. if (this.allowPlugin()) {
  878. ret = document.getElementById('deployJavaPlugin');
  879. }
  880. return ret;
  881. },
  882. compareVersionToPattern: function(version, patternArray,
  883. familyMatch, minMatch) {
  884. if (version == undefined || patternArray == undefined) {
  885. return false;
  886. }
  887. var matchData = version.match(version_regex_strict);
  888. if (matchData != null) {
  889. var index = 0;
  890. var result = new Array();
  891. for (var i = 1; i < matchData.length; ++i) {
  892. if ((typeof matchData[i] == 'string') && (matchData[i] != ''))
  893. {
  894. result[index] = matchData[i];
  895. index++;
  896. }
  897. }
  898. var l = Math.min(result.length, patternArray.length);
  899. // result contains what is installed in local machine
  900. // patternArray is what is being requested by application
  901. if (minMatch) {
  902. // minimum version match, return true if what we have (installed)
  903. // is greater or equal to what is requested. false otherwise.
  904. for (var i = 0; i < l; ++i) {
  905. var resultTemp = parseInt(result[i]);
  906. var patternArrayTemp = parseInt(patternArray[i]);
  907. if (resultTemp < patternArrayTemp) {
  908. return false;
  909. } else if (resultTemp > patternArrayTemp) {
  910. return true;
  911. }
  912. }
  913. return true;
  914. } else {
  915. for (var i = 0; i < l; ++i) {
  916. if (result[i] != patternArray[i]) return false;
  917. }
  918. if (familyMatch) {
  919. // family match - return true as long as what we have
  920. // (installed) matches up to the request pattern
  921. return true;
  922. } else {
  923. // exact match
  924. // result and patternArray needs to have exact same content
  925. return (result.length == patternArray.length);
  926. }
  927. }
  928. } else {
  929. return false;
  930. }
  931. },
  932. getBrowser: function() {
  933. if (this.browserName == null) {
  934. var browser = navigator.userAgent.toLowerCase();
  935. log('[getBrowser()] navigator.userAgent.toLowerCase() -> ' + browser);
  936. // order is important here. Safari userAgent contains mozilla,
  937. // IE 11 userAgent contains mozilla and netscape,
  938. // and Chrome userAgent contains both mozilla and safari.
  939. if ((browser.indexOf('msie') != -1) && (browser.indexOf('opera') == -1)) {
  940. this.browserName = 'MSIE';
  941. this.browserName2 = 'MSIE';
  942. } else if (browser.indexOf('trident') != -1 || browser.indexOf('Trident') != -1) {
  943. this.browserName = 'MSIE';
  944. this.browserName2 = 'MSIE';
  945. } else if (browser.indexOf('iphone') != -1) {
  946. // this included both iPhone and iPad
  947. this.browserName = 'Netscape Family';
  948. this.browserName2 = 'iPhone';
  949. } else if ((browser.indexOf('firefox') != -1) && (browser.indexOf('opera') == -1)) {
  950. this.browserName = 'Netscape Family';
  951. this.browserName2 = 'Firefox';
  952. } else if (browser.indexOf('chrome') != -1) {
  953. this.browserName = 'Netscape Family';
  954. this.browserName2 = 'Chrome';
  955. } else if (browser.indexOf('safari') != -1) {
  956. this.browserName = 'Netscape Family';
  957. this.browserName2 = 'Safari';
  958. } else if ((browser.indexOf('mozilla') != -1) && (browser.indexOf('opera') == -1)) {
  959. this.browserName = 'Netscape Family';
  960. this.browserName2 = 'Other';
  961. } else if (browser.indexOf('opera') != -1) {
  962. this.browserName = 'Netscape Family';
  963. this.browserName2 = 'Opera';
  964. } else {
  965. this.browserName = '?';
  966. this.browserName2 = 'unknown';
  967. }
  968. log('[getBrowser()] Detected browser name:'+ this.browserName +
  969. ', ' + this.browserName2);
  970. }
  971. return this.browserName;
  972. },
  973. testUsingActiveX: function(version) {
  974. var objectName = 'JavaWebStart.isInstalled.' + version + '.0';
  975. // we need the typeof check here for this to run on FF/Chrome
  976. // the check needs to be in place here - cannot even pass ActiveXObject
  977. // as arg to another function
  978. if (typeof ActiveXObject == 'undefined' || !ActiveXObject) {
  979. log('[testUsingActiveX()] Browser claims to be IE, but no ActiveXObject object?');
  980. return false;
  981. }
  982. try {
  983. return (new ActiveXObject(objectName) != null);
  984. } catch (exception) {
  985. return false;
  986. }
  987. },
  988. testForMSVM: function() {
  989. var clsid = '{08B0E5C0-4FCB-11CF-AAA5-00401C608500}';
  990. if (typeof oClientCaps != 'undefined') {
  991. var v = oClientCaps.getComponentVersion(clsid, "ComponentID");
  992. if ((v == '') || (v == '5,0,5000,0')) {
  993. return false;
  994. } else {
  995. return true;
  996. }
  997. } else {
  998. return false;
  999. }
  1000. },
  1001. testUsingMimeTypes: function(version) {
  1002. if (!navigator.mimeTypes) {
  1003. log ('[testUsingMimeTypes()] Browser claims to be Netscape family, but no mimeTypes[] array?');
  1004. return false;
  1005. }
  1006. for (var i = 0; i < navigator.mimeTypes.length; ++i) {
  1007. s = navigator.mimeTypes[i].type;
  1008. var m = s.match(/^application\/x-java-applet\x3Bversion=(1\.8|1\.7|1\.6|1\.5|1\.4\.2)$/);
  1009. if (m != null) {
  1010. if (this.compareVersions(m[1], version)) {
  1011. return true;
  1012. }
  1013. }
  1014. }
  1015. return false;
  1016. },
  1017. testUsingPluginsArray: function(version) {
  1018. if ((!navigator.plugins) || (!navigator.plugins.length)) {
  1019. return false;
  1020. }
  1021. var platform = navigator.platform.toLowerCase();
  1022. for (var i = 0; i < navigator.plugins.length; ++i) {
  1023. s = navigator.plugins[i].description;
  1024. if (s.search(/^Java Switchable Plug-in (Cocoa)/) != -1) {
  1025. // Safari on MAC
  1026. if (this.compareVersions("1.5.0", version)) {
  1027. return true;
  1028. }
  1029. } else if (s.search(/^Java/) != -1) {
  1030. if (platform.indexOf('win') != -1) {
  1031. // still can't tell - opera, safari on windows
  1032. // return true for 1.5.0 and 1.6.0
  1033. if (this.compareVersions("1.5.0", version) ||
  1034. this.compareVersions("1.6.0", version)) {
  1035. return true;
  1036. }
  1037. }
  1038. }
  1039. }
  1040. // if above dosn't work on Apple or Windows, just allow 1.5.0
  1041. if (this.compareVersions("1.5.0", version)) {
  1042. return true;
  1043. }
  1044. return false;
  1045. },
  1046. IEInstall: function() {
  1047. location.href = constructGetJavaURL(
  1048. ((this.returnPage != null) ?
  1049. ('&returnPage=' + this.returnPage) : '') +
  1050. ((this.locale != null) ?
  1051. ('&locale=' + this.locale) : '') +
  1052. ((this.brand != null) ? ('&brand=' + this.brand) : ''));
  1053. // should not actually get here
  1054. return false;
  1055. },
  1056. done: function (name, result) {
  1057. },
  1058. FFInstall: function() {
  1059. location.href = constructGetJavaURL(
  1060. ((this.returnPage != null) ?
  1061. ('&returnPage=' + this.returnPage) : '') +
  1062. ((this.locale != null) ?
  1063. ('&locale=' + this.locale) : '') +
  1064. ((this.brand != null) ? ('&brand=' + this.brand) : '') +
  1065. ((this.installType != null) ?
  1066. ('&type=' + this.installType) : ''));
  1067. // should not actually get here
  1068. return false;
  1069. },
  1070. // return true if 'installed' (considered as a JRE version string) is
  1071. // greater than or equal to 'required' (again, a JRE version string).
  1072. compareVersions: function(installed, required) {
  1073. var a = installed.split('.');
  1074. var b = required.split('.');
  1075. for (var i = 0; i < a.length; ++i) {
  1076. a[i] = Number(a[i]);
  1077. }
  1078. for (var i = 0; i < b.length; ++i) {
  1079. b[i] = Number(b[i]);
  1080. }
  1081. if (a.length == 2) {
  1082. a[2] = 0;
  1083. }
  1084. if (a[0] > b[0]) return true;
  1085. if (a[0] < b[0]) return false;
  1086. if (a[1] > b[1]) return true;
  1087. if (a[1] < b[1]) return false;
  1088. if (a[2] > b[2]) return true;
  1089. if (a[2] < b[2]) return false;
  1090. return true;
  1091. },
  1092. enableAlerts: function() {
  1093. // reset this so we can show the browser detection
  1094. this.browserName = null;
  1095. this.debug = true;
  1096. },
  1097. poll: function() {
  1098. this.refresh();
  1099. var postInstallJREList = this.getJREs();
  1100. if ((this.preInstallJREList.length == 0) &&
  1101. (postInstallJREList.length != 0)) {
  1102. clearInterval(this.myInterval);
  1103. if (this.returnPage != null) {
  1104. location.href = this.returnPage;
  1105. };
  1106. }
  1107. if ((this.preInstallJREList.length != 0) &&
  1108. (postInstallJREList.length != 0) &&
  1109. (this.preInstallJREList[0] != postInstallJREList[0])) {
  1110. clearInterval(this.myInterval);
  1111. if (this.returnPage != null) {
  1112. location.href = this.returnPage;
  1113. }
  1114. }
  1115. },
  1116. writePluginTag: function() {
  1117. var browser = this.getBrowser();
  1118. if (browser == 'MSIE') {
  1119. document.write('<' +
  1120. 'object classid="clsid:CAFEEFAC-DEC7-0000-0001-ABCDEFFEDCBA" ' +
  1121. 'id="deployJavaPlugin" width="0" height="0">' +
  1122. '<' + '/' + 'object' + '>');
  1123. } else if (browser == 'Netscape Family' && this.allowPlugin()) {
  1124. this.writeEmbedTag();
  1125. }
  1126. },
  1127. refresh: function() {
  1128. navigator.plugins.refresh(false);
  1129. var browser = this.getBrowser();
  1130. if (browser == 'Netscape Family' && this.allowPlugin()) {
  1131. var plugin = document.getElementById('deployJavaPlugin');
  1132. // only do this again if no plugin
  1133. if (plugin == null) {
  1134. this.writeEmbedTag();
  1135. }
  1136. }
  1137. },
  1138. writeEmbedTag: function() {
  1139. var written = false;
  1140. if (navigator.mimeTypes != null) {
  1141. for (var i=0; i < navigator.mimeTypes.length; i++) {
  1142. if (navigator.mimeTypes[i].type == this.mimeType) {
  1143. if (navigator.mimeTypes[i].enabledPlugin) {
  1144. document.write('<' +
  1145. 'embed id="deployJavaPlugin" type="' +
  1146. this.mimeType + '" hidden="true" />');
  1147. written = true;
  1148. }
  1149. }
  1150. }
  1151. // if we ddn't find new mimeType, look for old mimeType
  1152. if (!written) for (var i=0; i < navigator.mimeTypes.length; i++) {
  1153. if (navigator.mimeTypes[i].type == this.oldMimeType) {
  1154. if (navigator.mimeTypes[i].enabledPlugin) {
  1155. document.write('<' +
  1156. 'embed id="deployJavaPlugin" type="' +
  1157. this.oldMimeType + '" hidden="true" />');
  1158. }
  1159. }
  1160. }
  1161. }
  1162. }
  1163. }; // deployJava object
  1164. rv.writePluginTag();
  1165. if (rv.locale == null) {
  1166. var loc = null;
  1167. if (loc == null) try {
  1168. loc = navigator.userLanguage;
  1169. } catch (err) { }
  1170. if (loc == null) try {
  1171. loc = navigator.systemLanguage;
  1172. } catch (err) { }
  1173. if (loc == null) try {
  1174. loc = navigator.language;
  1175. } catch (err) { }
  1176. if (loc != null) {
  1177. loc.replace("-","_")
  1178. rv.locale = loc;
  1179. }
  1180. }
  1181. return rv;
  1182. }();