PageRenderTime 71ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 1ms

/src/scripts/aspera/connectinstaller-2.js

https://bitbucket.org/hcp/db_builder_customizations
JavaScript | 1411 lines | 989 code | 153 blank | 269 comment | 275 complexity | 7b02e4269cbccf43139ec89e5e93f11e MD5 | raw file
  1. /* Connect Installer: 0.0.0.63156 */
  2. // Aspera Generic Installer JavaScript Library
  3. // Revision: 2011-12-07
  4. //
  5. // Internal library
  6. /*//////////////////////////////////////////////////////////////////////////
  7. AW.AsperaInstaller
  8. */
  9. if (typeof AW === "undefined") var AW = {};
  10. AW.AsperaInstaller = function() {
  11. var that = this;
  12. var browser = AW.utils.browser;
  13. // Configuration section
  14. that.currentAppId = "Aspera.Installer.5";
  15. that.currentMimeType = "application/x-aspera-installer-5";
  16. that.installerPath = "";
  17. this.installerId = "aspera-installer";
  18. this.installerClsid = '531D5A4A-03D9-4404-AFF7-235A48E6B61E';
  19. this.cabVersion = '5,0,0,0';
  20. this.plugin = null;
  21. this.callback = null;
  22. initActiveX();
  23. that.callback = that.callbackDefault;
  24. // From the AsperaInstaller.prototype object literal
  25. this.installInProgress = false;
  26. this.installInstaller = function() {
  27. if (that.installInProgress || that.isInstallerAvailable())
  28. return;
  29. that.installInProgress = true;
  30. // Flag that survives page refresh (used by IE)
  31. if (AW.utils.parseSearchString('install') === '' && top === self) {
  32. // We are not running in an iframe. This is popup-specific code.
  33. var originParam = AW.utils.parseSearchString('origin');
  34. if (originParam != '') {
  35. originParam = "&origin=" + originParam;
  36. }
  37. window.location.search += "&install=true&path=" + this.installerPath + originParam;
  38. }
  39. // Start installation based on browser
  40. var macExt = navigator.platform.match(/Mac/) ? '-mac' : '';
  41. if (browser.is.ff) {
  42. extensionURI = AW.utils.joinPaths(this.installerPath, "/bin/aspera-installer") + macExt + ".xpi?" + AW.utils.randomString(5);
  43. // AW.utils.logger("Installer points to: " + extensionURI);
  44. window.location = extensionURI;
  45. //} else if (browser.is.chrome) {
  46. // The optional way. Java install.
  47. // startJarInstall();
  48. // The old way. Broken on Chrome v21+
  49. // extensionURI = AW.utils.joinPaths(this.installerPath, "/bin/aspera-installer") + macExt + ".crx?" + AW.utils.randomString(5);
  50. // AW.utils.logger("Installer points to: " + extensionURI);
  51. // window.location = extensionURI;
  52. } else if (browser.is.ie) {
  53. // AW.utils.logger("You're running IE.");
  54. if (top !== self) {
  55. setTimeout(startCabInstall, 1000);
  56. } else {
  57. startCabInstall();
  58. }
  59. } else if (browser.is.safari) {
  60. // AW.utils.logger("You're running Safari.");
  61. startJarInstall();
  62. }
  63. // Start polling
  64. that.detectPluginInstall();
  65. };
  66. this.setCallback = function(cb) {
  67. that.callback = cb;
  68. };
  69. this.checkProcesses = function() {
  70. if (!that.plugin) {
  71. that.initPlug();
  72. }
  73. return that.plugin.checkProcesses('npasperaweb.dll,asperaweb.ocx,npinstaller.dll');
  74. };
  75. // Downloads and executes and MSI or EXE signed by Aspera
  76. this.executeCommands = function(commands) {
  77. if (!that.isInstallerAvailable())
  78. return;
  79. that.initPlug();
  80. if (that.plugin == null) {
  81. // AW.utils.logger("Aspera Installer plugin failed to load");
  82. }
  83. that.plugin.executeCommands(commands, that.callback);
  84. };
  85. this.fixConnectPrecedence = function() {
  86. if (that.plugin == null) return;
  87. that.plugin.fixConnectPrecedence();
  88. };
  89. this.restartBrowser = function (dllName) {
  90. //if (that.plugin == null) return;
  91. //that.plugin.RestartIe(window.location.href);
  92. }
  93. this.restartIe = function (url) {
  94. if (that.plugin === null) {
  95. initActiveX();
  96. }
  97. if (that.plugin === null) {
  98. // Still no plugin? Die.
  99. return;
  100. }
  101. that.plugin.restartIe(url);
  102. }
  103. this.detectPluginInstall = function(callback) {
  104. if (that.isInstallerAvailable())
  105. {
  106. // AW.utils.logger('AsperaInstaller detected');
  107. navigator.plugins.refresh();
  108. window.location.reload();
  109. return;
  110. } else {
  111. // AW.utils.logger('AsperaInstaller not detected');
  112. }
  113. // Retry if we didn't succeed
  114. setTimeout( function() {
  115. that.detectPluginInstall(callback);
  116. }, 2000);
  117. };
  118. this.initPlug = function() {
  119. if (browser.is.ie)
  120. initActiveX();
  121. else
  122. initNp();
  123. }
  124. // Allows you to override where the installer is pulled from
  125. this.setInstallSource = function(url) {
  126. that.installerPath = url;
  127. };
  128. this.callbackDefault = function(state, desc, percentage) {
  129. // AW.utils.logger(state + " " + desc + " " + percentage); // Default impl
  130. };
  131. //////////////////////////////////////////////////////////////////////
  132. // Version check
  133. this.isInstallerAvailable = function() {
  134. if (browser.is.ie) {
  135. if (that.plugin == null)
  136. initActiveX();
  137. return that.plugin != null;
  138. } else {
  139. AW.utils.reloadPlugins();
  140. return AW.utils.browser.hasMimeType(that.currentMimeType);
  141. }
  142. };
  143. this.installerUpdateAvailable = function() {
  144. return !that.isInstallerAvailable();
  145. };
  146. //////////////////////////////////////////////////////////////////////^M
  147. // Connect Version Verification
  148. this.hasHiddenUpdatedAsperaWeb = function(latestVersion, installedVersion) {
  149. // Sometimes Firefox on OS X VM's have a problem
  150. // loading a newly installed Aspera Web plugin. awInstaller
  151. // has a method to check the installed version directly and will
  152. // report that version number back.
  153. var hiddenVersion;
  154. if (!that.plugin) {
  155. that.initPlug();
  156. }
  157. if (!latestVersion) {
  158. return false;
  159. }
  160. try {
  161. hiddenVersion = that.plugin.getConnectVersion();
  162. if (hiddenVersion &&
  163. !AW.utils.versionLessThan(hiddenVersion, latestVersion))
  164. {
  165. // The hiddenVersion is at least the latestVersion.
  166. if (installedVersion && !AW.utils.versionLessThan(installedVersion, hiddenVersion)) {
  167. // In this case, we don't care if the installedVersion is
  168. // accurately reported.
  169. return false;
  170. }
  171. return true;
  172. } else {
  173. return false;
  174. }
  175. } catch (e) {
  176. // awInstaller doesn't support the method getConnectVersion.
  177. return false;
  178. }
  179. };
  180. //////////////////////////////////////////////////////////////////////
  181. // IE support
  182. function startCabInstall(id) {
  183. var s,
  184. el,
  185. cabFile;
  186. if (navigator.platform === 'Win32') {
  187. // 32-bit IE
  188. cabFile = AW.utils.joinPaths(that.installerPath, '/bin/npinstallhelper.cab')
  189. } else {
  190. // 64-bit IE
  191. cabFile = AW.utils.joinPaths(that.installerPath, '/bin/npinstallhelper64.cab')
  192. }
  193. el = document.createElement('div');
  194. el.style.fontSize = '0';
  195. el.style.lineHeight = '0';
  196. s = '<object id="' + that.installerId + '" classid="CLSID:' + that.installerClsid + '" width="1" height="1" ';
  197. s += 'codebase="' + cabFile + '#version=' + that.cabVersion + '" >';
  198. s += '</object>';
  199. s += "\n";
  200. el.innerHTML = s;
  201. document.body.appendChild(el);
  202. }
  203. function initActiveX() {
  204. // Attempt to initialize plugins that don't trigger any UI
  205. if (browser.is.ie) {
  206. try {
  207. // Initial check for availability
  208. that.plugin = new ActiveXObject(that.currentAppId);
  209. // Create windowed plugin
  210. var el = document.createElement('div');
  211. el.style.fontSize = '0';
  212. el.style.lineHeight = '0';
  213. var s = '<object id="' + that.installerId + '" classid="CLSID:' + that.installerClsid + '" width="1" height="1">';
  214. s += '</object>';
  215. s += "\n";
  216. el.innerHTML = s;
  217. document.body.appendChild(el);
  218. that.plugin = document.getElementById(that.installerId);
  219. } catch (error) {
  220. // AW.utils.logger("Failed to initialize IE plugin");
  221. }
  222. }
  223. }
  224. //////////////////////////////////////////////////////////////////////
  225. // Common NPAPI support
  226. function initNp() {
  227. if (that.plugin != null) {
  228. return;
  229. }
  230. // Only insert the installer plugin if we think it exists
  231. // to prevent 'Install Missing Plugin' dialog with FF.
  232. if (AW.utils.browser.hasMimeType(that.currentMimeType)) {
  233. var el = document.createElement('div');
  234. el.style.fontSize = '0';
  235. el.style.lineHeight = '0';
  236. var s = '<object id="' + that.installerId + '" width="1" height="1" type="' + that.currentMimeType + '" >';
  237. s += '</object>';
  238. s += "\n";
  239. el.innerHTML = s;
  240. document.body.appendChild(el);
  241. }
  242. that.plugin = document.getElementById(that.installerId);
  243. }
  244. //////////////////////////////////////////////////////////////////////
  245. // Google support
  246. //////////////////////////////////////////////////////////////////////
  247. // Firefox support
  248. //////////////////////////////////////////////////////////////////////
  249. // Java support
  250. function javaAvailable() {
  251. var minVer = "1.5.0";
  252. jreList = deployJava.getJREs();
  253. if (!navigator.javaEnabled()){
  254. return false;
  255. }
  256. for (var i=0; i<jreList.length; i++){
  257. jreVer = jreList[i].toString();
  258. if (jreVer.indexOf("_") != -1)
  259. jreVer = jreVer.slice(0,jreVer.indexOf("_"));
  260. if (!that.versionLessThan(jreVer,minVer))
  261. return true;
  262. }
  263. return false;
  264. }
  265. function startJarInstall() {
  266. var baseUrl, codepath, code, jar, cbk, applet;
  267. codepath = "aspera/install/applet/InstallerApplet.class";
  268. code = "aspera.install.applet.InstallerApplet.class";
  269. jar = "aspera-installer-applet.jar";
  270. cbk = "awiJarCallback";
  271. window.awiJarCallback = function(state, description, percent) {
  272. that.callback(state, description, percent);
  273. };
  274. var appletElement = document.createElement('div');
  275. appletElement.style.fontSize = '0';
  276. appletElement.style.lineHeight = '0';
  277. appletElement.setAttribute('id','installer_applet_container');
  278. document.body.appendChild(appletElement);
  279. // If Java is broken, it's tough cookies.
  280. appletElement.innerHTML=
  281. '<applet id="installer_applet" ' +
  282. 'name="installer_applet" ' +
  283. 'height="0" ' +
  284. 'width="0" ' +
  285. 'code="' + code + '" '+
  286. 'codebase="' + AW.utils.joinPaths(that.installerPath, '/bin') + '" ' +
  287. 'archive="' + jar + '?t='+new Date().getTime()+'" ' +
  288. 'mayscript>' +
  289. '<param name="separate_jvm" value="true"/>' +
  290. '<param name="classloader_cache" value="false"/>' +
  291. '<param name="callback" ' +
  292. 'value="'+cbk+'"/>' +
  293. '<param name="useragent" '+
  294. 'value="'+navigator.userAgent+'"/>' +
  295. '<param name="pageurl" '+
  296. 'value="'+document.URL+'"/>' +
  297. '</applet>';
  298. // TODO: Ping applet. If available, startInstall.
  299. }
  300. // Continuation hook
  301. if (this.installerUpdateAvailable() &&
  302. AW.utils.parseSearchString('install') === "true" &&
  303. window.location.hash.indexOf('requiresrestart') === -1)
  304. {
  305. this.installerPath = AW.utils.parseSearchString('path') + '/';
  306. this.installInstaller();
  307. }
  308. };
  309. // Aspera Connect Installer JavaScript Library
  310. // Revision: 2011-01-12
  311. //
  312. // http://www.asperasoft.com/developer
  313. /*//////////////////////////////////////////////////////////////////////////
  314. AW.ConnectInstaller
  315. Requires AW.utils and AW.AsperaInstaller
  316. */
  317. AW.ConnectInstaller = function(aw_id, autoInstallLocation) {
  318. var that = this;
  319. // Preserve legacy compatibility, but allow 2.8+ users to
  320. // construct the object with a single argument, the autoInstallLocation.
  321. var autoInstallLocation = arguments.length === 1 ? aw_id + '/' : autoInstallLocation +'/';
  322. // New in Connect 3.1 Take a params object, optionally:
  323. // {
  324. // path : 'http://example.com',
  325. // language : 'en-US'
  326. // }
  327. var params;
  328. if (typeof arguments[0] === 'object') {
  329. params = arguments[0];
  330. if (params.path) {
  331. autoInstallLocation = params.path;
  332. }
  333. } else {
  334. params = {};
  335. }
  336. this.minVersion = '0';
  337. this.setLanguage = function(language) {
  338. // Language precedence will be as follows:
  339. // URL query string
  340. // language parameter sent when instantiating AW.ConnectInstaller
  341. // navigator.language or IE's version; navigator.userLanguage
  342. // default to "en-US"
  343. that.language = AW.utils.parseSearchString('awlang') || language || navigator.language ||
  344. navigator.userLanguage.replace(/(.*-)(.*)/, function(a, b, c) {return b + c.toUpperCase()}) || 'en-US';
  345. }
  346. this.setLanguage(params.language);
  347. ////////////////////////////////////////////////////////////////////
  348. // Callback helpers
  349. this.aspera_installer_callback_function;
  350. function createInstallerEventCallback(state, description, percent) {
  351. //logger("createInstallerEventCallback() - " + state + ", " + description + ", " + percent);
  352. var e = new that.ConnectInstallerEvent();
  353. e.init(state, percent, description);
  354. if (typeof(that.aspera_installer_callback_function) != 'undefined')
  355. that.aspera_installer_callback_function(e);
  356. }
  357. ////////////////////////////////////////////////////////////////////
  358. // ConnectInstaller
  359. this.installerPath = autoInstallLocation; // Root url of installation
  360. this.aspera_web_id = aw_id;
  361. this.applet_supported = true;
  362. this.os = "";
  363. this.awInstaller = new AW.AsperaInstaller();
  364. this.awInstaller.setCallback(createInstallerEventCallback);
  365. this.awId = "aspera-web-verify";
  366. this.asperaClsid = '531D5A4A-03D9-4404-AFF7-235A48E6B61E';
  367. this.currentMimeType = 'application/x-aspera-web';
  368. this.internalInstallLatest = function(callback) {
  369. if (!that.updateAvailable()) {
  370. createInstallerEventCallback("COMPLETE", "", 100);
  371. return;
  372. }
  373. if (callback != null)
  374. that.aspera_installer_callback_function = callback;
  375. if (that.continuationTimeout)
  376. clearTimeout(that.continuationTimeout);
  377. // First make sure that the aw installer is updated
  378. var connectInstaller = that;
  379. if (that.awInstaller.installerUpdateAvailable()) {
  380. // AW.utils.logger("ConnectInstaller.internalInstallLatest - Aspera installer update starting");
  381. that.awInstaller.setInstallSource(that.installerPath);
  382. that.awInstaller.setCallback(function(state, description, percent) {
  383. if (state == "COMPLETE") {
  384. // AW.utils.logger("ConnectInstaller.internalInstallLatest - Aspera installer finished. Continuing with Connect install");
  385. connectInstaller.internalInstallLatest(); // Continue with original execution
  386. } else {
  387. createInstallerEventCallback(state, description, percent);
  388. }
  389. });
  390. that.awInstaller.installInstaller(); // Async
  391. return;
  392. };
  393. that.originalVersion = that.awInstaller.plugin.getConnectVersion();
  394. // Override install completion
  395. that.awInstaller.setCallback(function(state, description, percent) {
  396. if (state == "COMPLETE") {
  397. that.awInstaller.fixConnectPrecedence();
  398. if (that.shouldRestart()) {
  399. createInstallerEventCallback("RESTART_REQUIRED", "", 0);
  400. return;
  401. }
  402. // Start polling for Connect
  403. that.detectConnectInstall();
  404. }
  405. createInstallerEventCallback(state, description, percent);
  406. });
  407. // Build list of commands to execute
  408. var commandList = "";
  409. if (that.removalTool)
  410. commandList += that.removalTool + "|";
  411. if (that.installPackage)
  412. commandList += that.installPackage;
  413. // AW.utils.logger("ConnectInstaller.internalInstallLatest - Commands: " + commandList);
  414. that.awInstaller.executeCommands(commandList); // Async
  415. };
  416. this.isUpgrade = function () {
  417. if (connectInstaller.installedVersion && connectInstaller.updateAvailable()) {
  418. // Connect is installed AND there is an update available
  419. return true;
  420. } else {
  421. return false
  422. }
  423. };
  424. this.installLatest = function(callback, type) {
  425. if (typeof(type) == "undefined") {
  426. var installerWindow = window.open(AW.utils.joinPaths(that.installerPath, 'install/auto/index.html?&origin=' + window.location.href), 'installer', 'menubar=no, resizable=no, scrollbars=no, status=no, titlebar=yes, width=700, height=420, top=12, left=12');
  427. } else if (type == "manual") {
  428. that.internalInstallLatest(callback);
  429. }
  430. };
  431. this.getAsperaInstaller = function() {
  432. return that.awInstaller;
  433. };
  434. this.restartBrowser = function () {
  435. //that.awInstaller.restartBrowser("npasperaweb.dll, asperaweb.ocx");
  436. var url = AW.utils.parseSearchString('origin');
  437. if (url === '') {
  438. url = window.location.href;
  439. }
  440. that.awInstaller.restartIe(url); // Address of the page to reopen
  441. };
  442. this.restartIe = function (url) {
  443. that.awInstaller.restartIe(url);
  444. };
  445. function detectUpdatedPlugin() {
  446. // Detect if Aspera Web plugin was replaced. Refresh the browser if true.
  447. // Useful for web installation performed in another browser.
  448. var firstPluginFilename, secondPluginFilename;
  449. for (var i = 0, l = navigator.plugins.length; i < l; i += 1 ) {
  450. // Loop through plugins and check for a change in the name
  451. if (navigator.plugins[i].filename.indexOf('Aspera Web') !== -1) {
  452. // Store the initial Aspera Web plugin name.
  453. firstPluginFilename = navigator.plugins[i].filename;
  454. }
  455. };
  456. navigator.plugins.refresh(false);
  457. for (var i = 0, l = navigator.plugins.length; i < l; i += 1 ) {
  458. if (navigator.plugins[i].filename.indexOf('Aspera Web') !== -1) {
  459. // Store the Aspera Web plugin name after reloading plugins.
  460. secondPluginFilename = navigator.plugins[i].filename;
  461. }
  462. };
  463. if (firstPluginFilename !== secondPluginFilename) {
  464. // Reload the document if the plugin name changed after refreshing plugins.
  465. document.location.reload(true)
  466. }
  467. }
  468. detectUpdatedPlugin();
  469. //////////////////////////////////////////////////////////////////////
  470. // Connect checks
  471. var installedVersion = null;
  472. var availableVersion = null;
  473. var installPackage = null; // MSI or DMG path
  474. var manualInstallPackage; // Vista needs a different download-able package.
  475. var removalTool = null; // Tool used to remove previous versions cleanly
  476. var browser = AW.utils.browser;
  477. function getConnectReleaseVersion (pluginEl) {
  478. // Supports checking Connect version for both pre-3.0 plugins
  479. // and 3.0 plugins.
  480. var version;
  481. try {
  482. // First, the 3.0 way.
  483. version = JSON.parse(pluginEl.queryConnectVersion()).release_version;
  484. } catch (e) {
  485. // Fall back to the pre-3.0 way.
  486. version = pluginEl.queryBuildVersion();
  487. }
  488. return version;
  489. }
  490. function checkVersions() {
  491. // Assumption that connectversions.js is loaded
  492. try {
  493. // We need available versions, first.
  494. that.versions = AW.connectVersions;
  495. if (!that.installPackage) {
  496. try {
  497. // AW.utils.logger("Parsing connect versions");
  498. // Find relevant OS
  499. for (var eIx=0; eIx<that.versions.entries.length; eIx++) {
  500. var e = that.versions.entries[eIx];
  501. if (e.navigator.platform == that.os) {
  502. that.availableVersion = e.version;
  503. // Find link for download package
  504. for (var lIx=0; lIx<e.links.length; lIx++) {
  505. var l = e.links[lIx];
  506. if (l.rel == 'enclosure-manual') {
  507. that.manualInstallPackage = AW.utils.joinPaths(that.installerPath, l.href);
  508. }
  509. if (l.rel == 'enclosure') {
  510. that.installPackage = AW.utils.joinPaths(that.installerPath, l.href);
  511. }
  512. if (l.rel == 'cleanup') {
  513. that.removalTool = AW.utils.joinPaths(that.installerPath, l.href);
  514. }
  515. }
  516. }
  517. }
  518. } catch(e) {
  519. // AW.utils.logger("Something failed when processing connectversions.js");
  520. }
  521. }
  522. if (!that.awInstaller.plugin) {
  523. // Load the installer plugin for version checking.
  524. that.awInstaller.initPlug();
  525. }
  526. if (that.awInstaller.plugin) {
  527. that.installedVersion = that.awInstaller.plugin.getConnectVersion();
  528. }
  529. if (!that.installedVersion) {
  530. // Fallback to query Connect itself for the version.
  531. if (browser.is.ie) {
  532. initConnectAx();
  533. if (that.controlAx != null) {
  534. that.installedVersion = getConnectReleaseVersion(that.controlAx);
  535. }
  536. } else {
  537. AW.utils.reloadPlugins();
  538. if (AW.utils.browser.hasMimeType(that.currentMimeType)) {
  539. initNp();
  540. if (that.controlNp != null) {
  541. that.installedVersion = getConnectReleaseVersion(that.controlNp);
  542. }
  543. }
  544. }
  545. }
  546. if (!that.originalVersion) {
  547. // If we never knew about the original version, then set it.
  548. that.originalVersion = that.installedVersion;
  549. }
  550. } catch(e) {
  551. // AW.utils.logger("Failed to detect Connect plugin");
  552. }
  553. if (that.availableVersion && that.installedVersion &&
  554. that.awInstaller.hasHiddenUpdatedAsperaWeb(that.availableVersion, that.installedVersion)) {
  555. setRestartRequiredFlag();
  556. }
  557. };
  558. parseNavigator()
  559. checkVersions();
  560. function setRestartRequiredFlag() {
  561. if (window.location.hash.indexOf('requiresrestart') === -1) {
  562. window.location.hash += 'requiresrestart';
  563. }
  564. }
  565. this.updateAvailable = function() {
  566. checkVersions();
  567. if (that.availableVersion == null) {
  568. // AW.utils.logger("ConnectInstaller.updateAvailable() might be too early. connectversions.js not parsed");
  569. }
  570. if (!that.installedVersion ||
  571. AW.utils.versionLessThan(that.installedVersion, that.availableVersion))
  572. {
  573. return true;
  574. }
  575. return false;
  576. };
  577. this.getLatestConnectVersion = function( os ) {
  578. return that.availableVersion;
  579. };
  580. this.asperaWebInstalled = function() {
  581. checkVersions();
  582. if (!that.installedVersion)
  583. return false;
  584. else
  585. return true;
  586. };
  587. this.detectConnectInstall = function(installer) {
  588. if (installer == null)
  589. installer = that;
  590. if (!that.updateAvailable()) {
  591. // AW.utils.logger('ConnectInstaller - Connect detected');
  592. createInstallerEventCallback("READY", "Aspera Connect is now available", 100);
  593. return;
  594. } else {
  595. // AW.utils.logger('ConnectInstaller - Connect not (yet) detected');
  596. }
  597. // Retry if we didn't succeed
  598. setTimeout( function() { // 2.7 support
  599. that.detectConnectInstall();
  600. }, 2000);
  601. };
  602. // After installation is completed, call this method to determine if a restart is required
  603. this.shouldRestart = function() {
  604. var currentVer, plug;
  605. var shortenVersionTo = function(versionText, places) {
  606. try {
  607. return versionText.split('.').slice(0, places).join('.');
  608. } catch (e) {
  609. return;
  610. }
  611. }
  612. if (typeof(that.originalVersion) != 'undefined' && that.originalVersion.length > 0) {
  613. // Restart IE
  614. if (browser.is.ie)
  615. return true;
  616. }
  617. // Sometimes navigator.refresh doesn't pick up the plugin. Or the plugin didn't
  618. // get ordered correctly when upgrading.
  619. navigator.plugins.refresh();
  620. for (var i=0; i<navigator.plugins.length; i++) {
  621. plug = navigator.plugins[i];
  622. if (/Aspera Web/.test(plug.name) && plug[0].type === that.currentMimeType) {
  623. // Only compare the first three places.
  624. currentVer = shortenVersionTo(plug.version, 3);
  625. break;
  626. }
  627. }
  628. if (!currentVer ||
  629. AW.utils.versionLessThan(currentVer, that.availableVersion)) {
  630. return true;
  631. }
  632. return false;
  633. };
  634. function defaultCallback(state, desc, percentage) {
  635. // AW.utils.logger(state + " " + desc + " " + percentage); // Default impl
  636. };
  637. /////////////////////////////////////////////////////////////
  638. // iFrame Auto Install
  639. this.iframeDomain = function() {
  640. // Needed for postMessage from parent window to iframe.
  641. function createUrl(url) {
  642. var url, domainUrl;
  643. domainUrl = [];
  644. // Domain URL needs to be in the form 'protocol://domain'
  645. url = url.split(/\//); // IE8 fails to add // to the array, other browsers do.
  646. // Clean the array of blank entries.
  647. for (var i = 0, l = url.length; i < l; i +=1) {
  648. if (url[i] !== '') {
  649. domainUrl.push(url[i]);
  650. }
  651. }
  652. domainUrl = domainUrl.slice(0,2);
  653. domainUrl.splice(1,0,'//');
  654. return domainUrl.join('');
  655. }
  656. if (that.installerPath.indexOf('http') === 0) {
  657. // We have absolute path for the installer path
  658. return createUrl(that.installerPath);
  659. } else {
  660. // We have a relative URL and the iframe domain comes from window.location.href
  661. return createUrl(window.location.href);
  662. }
  663. };
  664. this.startEmbeddedInstall = function(options) {
  665. // Start the iframe install.
  666. var iframeWrapper
  667. , iframeWidth
  668. , iframeHeight
  669. , divTitle
  670. , modalOverlay
  671. , iframe
  672. , parent;
  673. options = options || {};
  674. if (document.getElementById('aspera-iframe-container')) {
  675. // Aviod inserting the iframe twice.
  676. return;
  677. }
  678. if (options.installDismiss) {
  679. if (typeof options.installDismiss !== 'function') {
  680. throw new Error('startEmbeddedInstall: The "installDismiss" option must be a function.');
  681. }
  682. }
  683. if (options.installClose) {
  684. if (typeof options.installClose !== 'function') {
  685. throw new Error('startEmbeddedInstall: The "installClose" option must be a function.');
  686. }
  687. }
  688. if (options.prompt === 'false') {
  689. // Also accept a boolean in the form of a string.
  690. options.prompt = false;
  691. }
  692. // Inserting a stylesheet into the DOM for more manageable styles.
  693. AW.utils.loadFile(AW.utils.joinPaths(that.installerPath, 'install/auto-iframe/parent.css'), 'css');
  694. // Build and insert the iframe.
  695. iframeWrapper = document.createElement('div');
  696. iframeWrapper.id = 'aspera-iframe-container';
  697. iframeWrapper.className = iframeWrapper.id;
  698. iframeHeight = 220;
  699. iframeWidth = iframeHeight * 1.61;
  700. iframe = document.createElement('iframe');
  701. iframe.id = 'aspera-connect-installer';
  702. iframe.name = iframe.id;
  703. iframe.className = iframe.id;
  704. iframe.src = AW.utils.joinPaths(that.installerPath, '/install/auto-iframe/index.html#awlang=' + that.language + '&origin=' + window.location.href);
  705. iframe.scrolling = 'no';
  706. iframe.frameBorder = '0';
  707. iframeWrapper.appendChild(iframe);
  708. if (options.parentId) {
  709. // Insert the iframe with a button into the provided element.
  710. parent = document.getElementById(options.parentId);
  711. parent.appendChild(iframe);
  712. parent.style.height = iframeHeight + 'px';
  713. parent.style.width = iframeWidth + 'px';
  714. parent.style.visibility = 'visible';
  715. parent.style.display = 'block';
  716. } else {
  717. // Modal overlay doesn't get styles from a stylesheet.
  718. // Apply all styles with JS.
  719. parent = document.body;
  720. // Display the iframe as a modal dialog if no parentId is supplied.
  721. modalOverlay = document.createElement('div');
  722. modalOverlay.id = 'aspera-modal-overlay';
  723. modalOverlay.className = modalOverlay.id;
  724. modalOverlay.innerHTML = '&nbsp;';
  725. // Background image set dynamically because of image path.
  726. modalOverlay.style.backgroundImage = 'url('+ AW.utils.joinPaths(that.installerPath, 'install/auto-iframe/images/bg_white_75pct.png') + ')';
  727. // The iframe is set to 100% height and width of its container.
  728. iframeWrapper.style.height = iframeHeight + 'px';
  729. iframeWrapper.style.width = iframeWidth + 'px';
  730. // Center the iframe container.
  731. iframeWrapper.style.marginTop = (iframeHeight / 2) * -1 + 'px';
  732. iframeWrapper.style.marginLeft = (iframeWidth / 2) * -1 + 'px';
  733. parent.appendChild(modalOverlay);
  734. parent.appendChild(iframeWrapper);
  735. }
  736. function removeIframe(id) {
  737. // Takes a string or an array of id's.
  738. var container, parent;
  739. function removeEl(id) {
  740. container = document.getElementById(id);
  741. parent = container.parentNode;
  742. parent.removeChild(container);
  743. }
  744. if (typeof id === 'string') {
  745. removeEl(id);
  746. } else if (id instanceof Array) {
  747. for (var i = 0, l = id.length; i < l; i += 1) {
  748. try {
  749. removeEl(id[i]);
  750. } catch (e) {
  751. }
  752. }
  753. }
  754. };
  755. function handleMessage(event) {
  756. // iFrame installation: Handling of messages by the parent window.
  757. var iframe = event.source;
  758. // AW.utils.logger('iframeDomain: ' + that.iframeDomain());
  759. if (event.origin !== that.iframeDomain()) return;
  760. // AW.utils.logger('Parent window got the message: ' + event.data);
  761. if (window.location.hash.indexOf('embeddedinstall') === -1 && event.data === 'embeddedinstall') {
  762. // The hash does not already contain 'embeddedinstall'.
  763. window.location.hash += event.data;
  764. }
  765. if (event.data === 'iframeloaded') {
  766. // iframe continuation hook.
  767. iframe.postMessage('minversion='+that.minVersion, event.origin);
  768. if (window.location.hash.indexOf('embeddedinstall') !== -1 ||
  769. options.prompt === false)
  770. {
  771. // Parent tells the iframe that we are in the installation process.
  772. iframe.postMessage('installing', event.origin);
  773. } else {
  774. iframe.postMessage('notinstalling', event.origin);
  775. }
  776. if (window.location.hash.indexOf('requiresrestart') !== -1) {
  777. // Parent tells the iframe that we need a restart.
  778. // Ensures restart in case user only refreshed after install.
  779. // Iframe will show the 'restart' button.
  780. iframe.postMessage('requiresrestart', event.origin);
  781. }
  782. if (options.stylesheet) {
  783. iframe.postMessage('insertstylesheet=' + options.stylesheet + '?' + AW.utils.randomString(), event.origin);
  784. }
  785. }
  786. if (event.data === 'restorehash') {
  787. window.location.hash = window.location.hash.replace(/installing&/, '');
  788. window.location.hash = window.location.hash.replace(/embeddedinstall/, '');
  789. }
  790. if (event.data === 'installerror') {
  791. // Allow the iframe to trigger callbacks in the parent window.
  792. if (options.installError) {
  793. options.installError();
  794. };
  795. }
  796. if (event.data === 'connectready') {
  797. // Fire the connectReady callback if one is supplied.
  798. if (options.connectReady) {
  799. options.connectReady();
  800. };
  801. }
  802. if (event.data === 'reloadparent') {
  803. // Fire the connectReady callback if one is supplied.
  804. window.location.reload();
  805. }
  806. if (event.data === 'restartbrowser') {
  807. // Restart for IE upgrades.
  808. window.location.hash = window.location.hash.replace(/requiresrestart/, '');
  809. window.location.hash = window.location.hash.replace(/embeddedinstall/, '');
  810. that.awInstaller.restartIe(window.location.href);
  811. }
  812. if (event.data === 'removeiframe') {
  813. // Remove all elements related to the iframe from the parent.
  814. if (options.parentId) {
  815. removeIframe(options.parentId);
  816. } else {
  817. removeIframe(['aspera-modal-overlay', 'aspera-iframe-container']);
  818. }
  819. // Call the installDismiss callback, if it exists.
  820. if (options.installDismiss) {
  821. options.installDismiss();
  822. }
  823. }
  824. if (event.data === 'requiresrestart') {
  825. // Fire the connectReady callback if one is supplied.
  826. window.location.hash.replace(/embeddedinstall/, '');
  827. if (window.location.hash.indexOf('requiresrestart') === -1) {
  828. window.location.hash += 'requiresrestart';
  829. }
  830. }
  831. }
  832. // Set listener for messages from the iframe installer.
  833. if (window.addEventListener){
  834. window.addEventListener("message", handleMessage, false);
  835. } else {
  836. window.attachEvent("onmessage", handleMessage);
  837. }
  838. };
  839. this.startExternalInstall = function() {
  840. // Start the popup install.
  841. installerWindow = window.open(AW.utils.joinPaths(that.installerPath, 'install/auto/index.html' +
  842. '?'+ 'minversion=' + that.minVersion + '#awlang=' + that.language + '&'),
  843. 'installer', 'menubar=no, resizable=no, scrollbars=no, ' +
  844. 'status=no, titlebar=yes, width=700, height=420, top=12, left=12');
  845. // TODO - Marco: Add feature - Setup communication between popup
  846. // and the window that opened it so 'connectReady' events can be passed
  847. // around with postMessage.
  848. };
  849. this.init = function(options) {
  850. // options:
  851. // minVersion : If user version is equal to or greater than this version, no upgrade will be shown.
  852. // connectReady : Callback to be called when installation is complete.
  853. // install : Callback if an install is required.
  854. // noInstall: Callback no install available. Takes a 'code' and 'description' argument.
  855. ////////////
  856. // The parent element, if supplied, should have style="display:none" so
  857. // it doesn't take up unnecessary space when not needed.
  858. options = options || {};
  859. // minVersion is the supplied value or it is set to the highest available version.
  860. options.minVersion = options.minVersion || that.availableVersion;
  861. this.minVersion = options.minVersion;
  862. if (connectInstaller.installedVersion &&
  863. !AW.utils.versionLessThan(connectInstaller.installedVersion, options.minVersion) &&
  864. options.connectReady)
  865. {
  866. // OK - Connect version passes minVersion test.
  867. options.connectReady();
  868. return;
  869. }
  870. if (connectInstaller.installedVersion && // The installedVersion could be undefined and versionLessThan can't deal.
  871. AW.utils.versionLessThan(connectInstaller.installedVersion, options.minVersion) &&
  872. options.install)
  873. {
  874. // minVersion supplied, but installedVersion is less than the minVersion
  875. options.install();
  876. return;
  877. }
  878. if (!connectInstaller.installedVersion && options.install) {
  879. // Connect is not installed.
  880. options.install();
  881. return;
  882. }
  883. };
  884. //////////////////////////////////////////////////////////////////////
  885. // Documentation helpers
  886. this.setUserDocsLocation = function(url) {
  887. // Takes a custom URL for documentation if the SDK user hosts the docs.
  888. that.customUserDocsLocation = url;
  889. };
  890. this.userDocsLocation = function() {
  891. // return the default documentation location if one isn't set by the user.
  892. return that.customUserDocsLocation || 'http://download.asperasoft.com/download/docs/connect/2.8.1/';
  893. }
  894. //////////////////////////////////////////////////////////////////////
  895. // Platform checks
  896. function parseNavigator() {
  897. // This function actually sets the user's platform, mainly for lookup
  898. // in connectversions.js.
  899. var agent = navigator.userAgent;
  900. // change all of the windows lines to
  901. // agent.indexOf("Windows") != -1) that.os = "Win32";
  902. if (agent.indexOf("Windows NT 6.0") != -1) that.os = "Win32-Vista"; //Vista
  903. if (agent.indexOf("Windows NT 6.1") != -1) that.os = "Win32"; //Win7
  904. if (agent.indexOf("Windows NT 6.2") != -1) that.os = "Win32"; //Win8
  905. if (agent.indexOf("Windows NT 5") != -1) that.os = "Win32"; //Win XP and 2003
  906. if (agent.indexOf("Win64") !== -1) that.os = "Win64";
  907. if (agent.indexOf("Windows NT 6.0") != -1 && agent.indexOf("Win64") !== -1) that.os = "Win64-Vista"; //Vista 64
  908. if (agent.indexOf("Intel Mac") != -1) that.os = "MacIntel";
  909. if (agent.indexOf("PPC Mac") != -1) that.os = "MacPPC";
  910. if (agent.indexOf("Linux") != -1) that.os = "Linux i686";
  911. if (agent.indexOf("Linux x86_64") != -1) that.os = "Linux x86_64";
  912. if ((/Firefox\/[23]/.test(agent)) ||
  913. ((agent.indexOf("Chrome") != -1) && (that.os === "Win32" || that.os === "Win32-Vista")) ||
  914. (agent.indexOf("Linux x86_64") != -1) ||
  915. (agent.indexOf("Linux") != -1) ||
  916. (agent.indexOf("Windows NT 5.0") != -1) ||
  917. (agent.indexOf("PPC Mac") != -1)) {
  918. that.applet_supported = false;
  919. }
  920. if (that.os === "MacIntel" && /Mac OS X 10[._]4/.test(agent) && /Firefox\/3|Safari/.test(agent)) {
  921. that.os = "MacIntel-legacy";
  922. that.applet_supported = true;
  923. }
  924. if (that.os === "MacIntel" && /Mac OS X 10[._]6/.test(agent) && /Version\/5.0/.test(agent) ) {
  925. that.applet_supported = false;
  926. }
  927. };
  928. this.getEnvSupportInfo = function () {
  929. // If something needs to be installed, help devs
  930. // ask if the environment is suitable.
  931. // Return an object containing:
  932. // description: "describes the special case"
  933. // platform: The platform key used for lookup in connectinstaller.js,
  934. // if different than navigator.platform.
  935. // package: "path to download package if available"
  936. // isSupported: bool. Is connect supported in this special case?
  937. // downloadOnly: bool. Is downloading the installer the only available option in this case?
  938. // code: Environment code for special environments
  939. // Browser and platform tests used to find 'special case' environments.
  940. // Special cases will get either an older download for that OS,
  941. // or a message saying that the env is not supported.
  942. var uAgent,
  943. uPlatform,
  944. docStyle,
  945. isMacIntel,
  946. isMacIntel10_4,
  947. isMacIntel10_6,
  948. isSupportedOS,
  949. isSupportedBrowser,
  950. envProfiles;
  951. uAgent = navigator.userAgent;
  952. uPlatform = navigator.platform;
  953. docStyle = document.documentElement.style;
  954. isMacIntel = /MacIntel/.test(uPlatform);
  955. isMacIntel10_4 = isMacIntel && /Mac OS X 10[._]4/.test(uAgent);
  956. isMacIntel10_5 = isMacIntel && /Mac OS X 10[._]5/.test(uAgent);
  957. isMacIntel10_6 = isMacIntel && /Mac OS X 10[._]6/.test(uAgent);
  958. // Supported OS's:
  959. // Windows (32-bit and 64-bit, NT 5.1 or higher, "XP")
  960. // MacIntel and MacPPC (version 10.4 or higher)
  961. // Linux (32 and 64)
  962. isSupportedOS = (/Win/.test(uPlatform) && !AW.utils.versionLessThan(uAgent.match(/Windows NT (\d.\d)/)[1], '5.1')) ||
  963. (/Mac/.test(uPlatform) && parseInt(uAgent.match(/OS X 10[._](\d+)/)[1]) >= 4) ||
  964. (/Linux/.test(uPlatform));
  965. // Supported Browsers:
  966. // Firefox (version 3 or higher)
  967. // Safari (Mac only, version 4 or higher)
  968. // Chrome (any version)
  969. // IE (version 7 or higher)
  970. isSupportedBrowser = (AW.utils.browser.is.ff && parseInt(uAgent.match(/Firefox\/(\d+)/)[1]) >= 3) ||
  971. (AW.utils.browser.is.safari && /Mac/.test(uPlatform) && uAgent.match(/Version\/(\d+)/).length > 0 && parseInt(uAgent.match(/Version\/(\d+)/)[1]) >= 4) ||
  972. (AW.utils.browser.is.chrome) ||
  973. (AW.utils.browser.is.gteIe7);
  974. envProfiles = {
  975. // Be careful when adding special cases to test. They must be mutually exclusive.
  976. isNotWhiteListed : {
  977. // This is the ONE test for unsupported browsers and OS's.
  978. // All other tests are for cases that fall inside (isSupportedOS && isSupportedBrowser).
  979. test : !(isSupportedOS && isSupportedBrowser),
  980. description : "Unsupported browser or operating system.",
  981. code : (function() {
  982. var specifics = function () {
  983. if (!isSupportedOS) {
  984. return 'unsupportedOS';
  985. }
  986. if (!isSupportedBrowser) {
  987. return 'unsupportedBrowser';
  988. }
  989. if (!isSupportedOS && !isSupportedBrowser) {
  990. return 'unsupportedBrowserAndOS';
  991. }
  992. };
  993. return specifics();
  994. }()),
  995. isSupported : false
  996. },
  997. isChrome : {
  998. test : (uAgent.toLowerCase().indexOf('chrome') > -1),
  999. description: "Google Chrome",
  1000. code: "chromeBrowser",
  1001. downloadOnly: true,
  1002. isSupported:true
  1003. },
  1004. safari4MacIntel10_4 : {
  1005. // Legacy install supported. Safari 4 is the newest version available for OS X 10.4.
  1006. // Download only link to 2.7.2 legacy package
  1007. test : ('WebkitAppearance' in docStyle && /Version\/[34]./.test(uAgent) && isMacIntel10_4),
  1008. description : "Safari 4, Mac Intel OS X 10.4",
  1009. platform : 'MacIntel-legacy',
  1010. code: "legacy10_4Safari4_0",
  1011. downloadOnly: true,
  1012. isSupported : true
  1013. },
  1014. safari4MacIntel10_5 : {
  1015. // Safari 5 is the newest version available for OS X 10.5.
  1016. // Ask for browser upgrade.
  1017. // Download only link to current package
  1018. test : ('WebkitAppearance' in docStyle && /Version\/4./.test(uAgent) && isMacIntel10_5),
  1019. description : "Safari 4, Mac Intel OS X 10.4",
  1020. platform : 'MacIntel',
  1021. code: "10_5Safari4_0",
  1022. downloadOnly: true,
  1023. isSupported : true
  1024. },
  1025. safari5_0MacIntel10_5 : {
  1026. // Safari 5.0.x is the newest version available for OS X 10.5.
  1027. // Browser upgrade message.
  1028. // Download only link to current package.
  1029. test : ('WebkitAppearance' in docStyle && /Version\/5.0/.test(uAgent) && isMacIntel10_5),
  1030. description : "Safari 5, Mac Intel OS X 10.5",
  1031. platform : 'MacIntel',
  1032. code: "10_5Safari5_0",
  1033. downloadOnly: true,
  1034. isSupported: true
  1035. },
  1036. safari5_0MacIntel10_6 : {
  1037. // Safari 5.1 is the latest Safari version available for OS X 10.6.
  1038. // Give 'browser upgrade' message.
  1039. // Download only link to the current package.
  1040. test : ('WebkitAppearance' in docStyle && /Version\/5.0/.test(uAgent) && isMacIntel10_6),
  1041. description : "It looks like you're using an old version of Safari. Upgrade to the latest version for the best file-transfer experience. <br /><a href='http://www.apple.com/safari/'>Get the latest Safari browser now</a>. <p>If you do not want to upgrade your browser now, download the installer from the link below. Please note: For Safari 5.0, the plug-in will only work in 32-bit mode.</p>",
  1042. platform : 'MacIntel',
  1043. code: "10_6Safari5_0",
  1044. downloadOnly: true,
  1045. isSupported : true
  1046. },
  1047. firefox3MacIntel10_4 : {
  1048. // Mac Firefox 3.6 10.4, give link to 2.7.2 legacy package. No message.
  1049. // On PPC, 3.6 is the highest FF available.
  1050. test : ('MozAppearance' in docStyle && /Firefox\/3./.test(uAgent) && isMacIntel10_4),
  1051. platform : 'MacIntel-legacy',
  1052. downloadOnly: true,
  1053. isSupported : true
  1054. },
  1055. firefox3MacIntel10_5Plus : {
  1056. // Mac Firefox 3.6, OS X 10.5+. Give 'browser upgrade' message.
  1057. test : ('MozAppearance' in docStyle && /Firefox\/3./.test(uAgent) && /MacIntel/.test(uPlatform) && !isMacIntel10_4),
  1058. description : "Firefox 3, OS X 10.5 or higher is not supported.",
  1059. code: "firefox310_5Plus",
  1060. isSupported : false
  1061. },
  1062. firefox3Win : {
  1063. // Upgrade Firefox
  1064. test : ('MozAppearance' in docStyle && /Firefox\/3./.test(uAgent) && /^Win/.test(uPlatform)),
  1065. description : "Firefox 3.x on Windows is not supported. Upgrade browser.",
  1066. code: "firefox3Win",
  1067. isSupported : false
  1068. },
  1069. firefox3Linux : {
  1070. // Upgrade Firefox
  1071. test : ('MozAppearance' in docStyle && /Firefox\/3./.test(uAgent) && /^Linux/.test(uPlatform)),
  1072. description : "Firefox 3.x on Linux is not supported. Upgrade browser.",
  1073. code: "firefox3Linux",
  1074. isSupported : false
  1075. },
  1076. win8Ie10_64bit : {
  1077. // Plugins are broken in IE10 64-bit tile app.
  1078. test : (AW.utils.browser.is.ie && /Windows NT 6.2/.test(uAgent) && /MSIE 10/.test(uAgent) && /Win64/.test(uPlatform)),
  1079. description : "Unsupported browser configuration",
  1080. code : "unsupportedBrowser",
  1081. isSupported : false
  1082. },
  1083. linux32 : {
  1084. test: (/Linux i686/.test(uPlatform)),
  1085. description : "Please download and run the installer script.",
  1086. code: "linux32",
  1087. platform: 'Linux i686',
  1088. downloadOnly: true,
  1089. isSupported : true
  1090. },
  1091. linux64 : {
  1092. test: (/Linux x86_64/.test(uPlatform)),
  1093. description : "Please download and run the installer script.",
  1094. code: "linux64",
  1095. downloadOnly: true,
  1096. isSupported : true
  1097. }
  1098. };
  1099. generateResult = function() {
  1100. // If we have a 'special case', use the object to customize the response.
  1101. for ( profile in envProfiles) {
  1102. if (envProfiles.hasOwnProperty(profile) && envProfiles[profile].test) {
  1103. platform = envProfiles[profile].platform;
  1104. return {
  1105. description: envProfiles[profile].description || '',
  1106. code: envProfiles[profile].code || '',
  1107. packageURL: that.manualInstallPackage || that.installPackage || '',
  1108. packageVersion: that.availableVersion || '',
  1109. downloadOnly: envProfiles[profile].downloadOnly || false,
  1110. isSupported: envProfiles[profile].isSupported,
  1111. platform: envProfiles[profile].platform || window.navigator.platform
  1112. };
  1113. }
  1114. }
  1115. // Not a special case. Build a meaningful response object.
  1116. return {
  1117. isSupported: true,
  1118. code: '',
  1119. packageURL: that.manualInstallPackage || that.installPackage || '',
  1120. packageVersion: that.availableVersion || '',
  1121. downloadOnly: false,
  1122. description: '',
  1123. platform: window.navigator.platform
  1124. };
  1125. };
  1126. return generateResult();
  1127. };
  1128. // This func name is a misnomer. Deprecated from prev api
  1129. this.platformSupportsApplet = function() {
  1130. return that.platformSupportsConnect();
  1131. };
  1132. this.platformSupportsConnect = function() {
  1133. return (that.os != "");
  1134. };
  1135. //////////////////////////////////////////////////////////////////////
  1136. // IE support
  1137. function initConnectAx() {
  1138. if (document.getElementById(that.awId)) {
  1139. that.controlAx = document.getElementById(that.awId);
  1140. return;
  1141. }
  1142. var el = document.createElement('div');
  1143. el.style.overflow = 'hidden'; // Fix pre-2.8 escaping AW plugin text. #15730.
  1144. el.style.fontSize = '0';
  1145. el.style.lineHeight = '0';
  1146. var s = '<object id="' + that.awId + '" width="1" height="1" type="application/x-aspera-web" >';
  1147. s += '</object>';
  1148. s += "\n";
  1149. el.innerHTML = s;
  1150. document.body.appendChild(el);
  1151. that.controlAx = document.getElementById(that.awId);
  1152. };
  1153. //////////////////////////////////////////////////////////////////////
  1154. // Common NPAPI support
  1155. // Handle to the plugin object
  1156. function initNp() {
  1157. if (document.getElementById(that.awId)) {
  1158. that.controlNp = document.getElementById(that.awId);
  1159. return;
  1160. }
  1161. var el = document.createElement('div');
  1162. el.style.fontSize = '0';
  1163. el.style.lineHeight = '0';
  1164. var s = '<object id="' + that.awId + '" width="1" height="1" type="application/x-aspera-web" >';
  1165. s += '<param name="AW_IMGSRV" value="" />';
  1166. s += '</object>';
  1167. s += "\n";
  1168. el.innerHTML = s;
  1169. document.body.appendChild(el);
  1170. that.controlNp = document.getElementById(that.awId);
  1171. };
  1172. //////////////////////////////////////////////////////////////////////
  1173. // Google support
  1174. //////////////////////////////////////////////////////////////////////
  1175. // Firefox support
  1176. //////////////////////////////////////////////////////////////////////
  1177. // Java support
  1178. this.javaAvailable = function() {
  1179. var minVer = "1.5.0";
  1180. jreList = deployJava.getJREs();
  1181. if (!navigator.javaEnabled()){
  1182. return false;
  1183. }
  1184. for (var i=0; i<jreList.length; i++){
  1185. jreVer = jreList[i].toString();
  1186. if (jreVer.indexOf("_") != -1) jreVer = jreVer.slice(0,jreVer.indexOf("_"));
  1187. if (!AW.utils.versionLessThan(jreVer,minVer)) return true;
  1188. }
  1189. return false;
  1190. };
  1191. this.ConnectInstallerEvent = function() {
  1192. var that = this;
  1193. // A ConnectInstallerEvent is passed in the callback during the
  1194. // java-applet-based installer. Each event has these properties:
  1195. //
  1196. // 1) state: one of "START", "COMPLETE", "DOWNLOAD", "INSTALL",
  1197. // or "ERROR"
  1198. // 2) description: A user-friendly description of the event.
  1199. // 3) percent: The overall progress toward completion.
  1200. // 4) exceptions: An Array of exceptional conditions that may
  1201. // be important. Currently, the only possible condition is
  1202. // ConnectInstallerEvent.IE_PLUGIN_NOT_INSTALLED
  1203. // which can only happen during the "COMPLETE" event.
  1204. //
  1205. this.IE_PLUGIN_NOT_INSTALLED = "Plugin installation for Internet Explorer failed.";
  1206. this.init = function(state, percent, description) {
  1207. that.state = state + "";
  1208. loadExceptions(); // modifies this.state
  1209. that.description = convertStateToString(state,description);
  1210. that.percent = inferPercent(state,percent);
  1211. };
  1212. //Internal use only. Not part of the API.
  1213. function loadExceptions() {
  1214. var exceptions = new Array();
  1215. switch (that.state) {
  1216. case "COMPLETE-NO-IE":
  1217. exceptions.push(that.IE_PLUGIN_NOT_INSTALLED);
  1218. break;
  1219. default:
  1220. break;
  1221. }
  1222. if (that.state == "COMPLETE-NO-IE") {
  1223. // The lack of IE support should be communicated in something
  1224. // other than 'state'.
  1225. that.state = "COMPLETE";
  1226. }
  1227. };
  1228. //Internal use only. Not part of the API.
  1229. function inferPercent(state,percent) {
  1230. switch (state) {
  1231. case "START": return 0;
  1232. case "COMPLETE":
  1233. case "READY": return 100;
  1234. case "COMPLETE-NO-IE": return 100;
  1235. case "DOWNLOAD":
  1236. case "INSTALL":
  1237. case "ERROR":
  1238. default: return percent;
  1239. }
  1240. };
  1241. //Internal use only. Not part of the API.
  1242. function convertStateToString(state,description) {
  1243. s = "";
  1244. var lstate = ""+state;
  1245. switch (lstate) {
  1246. case "START": s="Starting the installation."; break;
  1247. case "DOWNLOAD": s="Downloading Aspera Connect."; break;
  1248. case "READY": s="Aspera Connect is ready."; break;
  1249. case "COMPLETE": s="Installation complete."; break;
  1250. case "COMPLETE-NO-IE": s="Installation complete with no support for Internet Explorer."; break;
  1251. case "ERROR": s=description; break;
  1252. case "INSTALL": s="Installing Aspera Connect."; break;
  1253. default: s="Installing Aspera Connect.";
  1254. }
  1255. return s;
  1256. }
  1257. };
  1258. };