|
5 | 5 | (function($) { |
6 | 6 | 'use strict'; |
7 | 7 |
|
| 8 | + /** |
| 9 | + * Check to see if we can start an autodownload |
| 10 | + * @returns {boolean} |
| 11 | + */ |
| 12 | + function canAutodownload () { |
| 13 | + var isIELT9 = window.Mozilla.Client.platform === 'windows' && /MSIE\s[1-8]\./.test(navigator.userAgent); |
| 14 | + |
| 15 | + // IE11 safe check for determining if we've already downloaded Thunderbird |
| 16 | + var lowercaseQuery = window.location.search.toLowerCase(); |
| 17 | + var isDownloaded = /([?|&]+downloaded=true)/.test(lowercaseQuery) === true; |
| 18 | + |
| 19 | + return !isDownloaded && !isIELT9; |
| 20 | + } |
| 21 | + |
8 | 22 | // Only do this on the autodownload page. |
9 | 23 | if ($('body').attr('id') == 'thunderbird-download') { |
10 | | - var isIELT9 = window.Mozilla.Client.platform === 'windows' && /MSIE\s[1-8]\./.test(navigator.userAgent); |
| 24 | + if (!canAutodownload()) { |
| 25 | + return; |
| 26 | + } |
11 | 27 | var downloadURL; |
12 | 28 | var downloadChannelRegex = /download_channel=(esr|beta|daily)/; |
13 | 29 | var downloadChannel = downloadChannelRegex.exec(window.location.search); |
|
37 | 53 | // Track auto downloads - trackLink( url, linkType ) |
38 | 54 | window._paq.push(['trackLink', downloadURL, 'download']) |
39 | 55 |
|
40 | | - // If user is not on an IE that blocks JS triggered downloads, start the |
41 | | - // platform-detected download a second after DOM ready event. We don't rely on |
| 56 | + // Start the platform-detected download a second after DOM ready event. We don't rely on |
42 | 57 | // the window load event as we have third-party tracking pixels. |
43 | | - if (!isIELT9) { |
44 | | - $(function() { |
45 | | - setTimeout(function() { |
46 | | - window.location.href = downloadURL; |
47 | | - }, 1000); |
48 | | - }); |
49 | | - } |
| 58 | + $(function() { |
| 59 | + setTimeout(function() { |
| 60 | + window.location.href = downloadURL; |
| 61 | + }, 1000); |
| 62 | + }); |
50 | 63 | } |
51 | 64 | } |
52 | 65 | })(window.jQuery); |
0 commit comments