only _blank links while downloading. fixed safari link after download
This commit is contained in:
parent
432a39d313
commit
859554ce21
|
@ -1,5 +1,4 @@
|
||||||
const testPilotGA = require('testpilot-ga');
|
const testPilotGA = require('testpilot-ga');
|
||||||
const { sendEvent } = require('./utils');
|
|
||||||
const Raven = require('raven-js');
|
const Raven = require('raven-js');
|
||||||
|
|
||||||
if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) {
|
if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) {
|
||||||
|
@ -12,6 +11,37 @@ const analytics = new testPilotGA({
|
||||||
tid: window.GOOGLE_ANALYTICS_ID
|
tid: window.GOOGLE_ANALYTICS_ID
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function sendEvent() {
|
||||||
|
return analytics.sendEvent
|
||||||
|
.apply(analytics, arguments)
|
||||||
|
.catch(() => 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function findMetric(href) {
|
||||||
|
switch (href) {
|
||||||
|
case 'https://www.mozilla.org/':
|
||||||
|
return 'mozilla';
|
||||||
|
case 'https://www.mozilla.org/about/legal':
|
||||||
|
return 'legal';
|
||||||
|
case 'https://testpilot.firefox.com/about':
|
||||||
|
return 'about';
|
||||||
|
case 'https://testpilot.firefox.com/privacy':
|
||||||
|
return 'privacy';
|
||||||
|
case 'https://testpilot.firefox.com/terms':
|
||||||
|
return 'terms';
|
||||||
|
case 'https://www.mozilla.org/privacy/websites/#cookies':
|
||||||
|
return 'cookies';
|
||||||
|
case 'https://github.com/mozilla/send':
|
||||||
|
return 'github';
|
||||||
|
case 'https://twitter.com/FxTestPilot':
|
||||||
|
return 'twitter';
|
||||||
|
case 'https://www.mozilla.org/firefox/new/?scene=2':
|
||||||
|
return 'download-firefox';
|
||||||
|
default:
|
||||||
|
return 'other';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ua = navigator.userAgent.toLowerCase();
|
const ua = navigator.userAgent.toLowerCase();
|
||||||
if (
|
if (
|
||||||
ua.indexOf('firefox') > -1 &&
|
ua.indexOf('firefox') > -1 &&
|
||||||
|
@ -26,5 +56,8 @@ if (
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.analytics = analytics;
|
module.exports = {
|
||||||
window.Raven = Raven;
|
Raven,
|
||||||
|
sendEvent,
|
||||||
|
findMetric
|
||||||
|
}
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
require('./common');
|
const { Raven, findMetric, sendEvent } = require('./common');
|
||||||
const FileReceiver = require('./fileReceiver');
|
const FileReceiver = require('./fileReceiver');
|
||||||
const { notify, findMetric, sendEvent, gcmCompliant } = require('./utils');
|
const { notify, gcmCompliant } = require('./utils');
|
||||||
const bytes = require('bytes');
|
const bytes = require('bytes');
|
||||||
const Storage = require('./storage');
|
const Storage = require('./storage');
|
||||||
const storage = new Storage(localStorage);
|
const storage = new Storage(localStorage);
|
||||||
|
const links = require('./links');
|
||||||
|
|
||||||
const $ = require('jquery');
|
const $ = require('jquery');
|
||||||
require('jquery-circle-progress');
|
require('jquery-circle-progress');
|
||||||
|
|
||||||
const Raven = window.Raven;
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
gcmCompliant()
|
gcmCompliant()
|
||||||
.then(function() {
|
.then(function() {
|
||||||
//link back to homepage
|
|
||||||
$('.send-new').attr('href', window.location.origin);
|
|
||||||
|
|
||||||
$('.send-new').click(function() {
|
$('.send-new').click(function() {
|
||||||
sendEvent('recipient', 'restarted', {
|
sendEvent('recipient', 'restarted', {
|
||||||
|
@ -46,6 +43,7 @@ $(document).ready(function() {
|
||||||
function download() {
|
function download() {
|
||||||
// Disable the download button to avoid accidental double clicks.
|
// Disable the download button to avoid accidental double clicks.
|
||||||
$('#download-btn').attr('disabled', 'disabled');
|
$('#download-btn').attr('disabled', 'disabled');
|
||||||
|
links.setOpenInNewTab(true);
|
||||||
|
|
||||||
storage.totalDownloads += 1;
|
storage.totalDownloads += 1;
|
||||||
|
|
||||||
|
@ -181,7 +179,8 @@ $(document).ready(function() {
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
Raven.captureException(err);
|
Raven.captureException(err);
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
});
|
})
|
||||||
|
.then(() => links.setOpenInNewTab(false));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
let links = []
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
links = document.querySelectorAll('a:not([target])')
|
||||||
|
})
|
||||||
|
|
||||||
|
function setOpenInNewTab(bool) {
|
||||||
|
if (bool === false) {
|
||||||
|
links.forEach(l => l.removeAttribute('target'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
links.forEach(l => l.setAttribute('target', '_blank'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
setOpenInNewTab
|
||||||
|
}
|
|
@ -1,12 +1,10 @@
|
||||||
/* global MAXFILESIZE EXPIRE_SECONDS */
|
/* global MAXFILESIZE EXPIRE_SECONDS */
|
||||||
require('./common');
|
const { Raven, findMetric, sendEvent } = require('./common');
|
||||||
const FileSender = require('./fileSender');
|
const FileSender = require('./fileSender');
|
||||||
const {
|
const {
|
||||||
copyToClipboard,
|
copyToClipboard,
|
||||||
notify,
|
notify,
|
||||||
gcmCompliant,
|
gcmCompliant,
|
||||||
findMetric,
|
|
||||||
sendEvent,
|
|
||||||
ONE_DAY_IN_MS
|
ONE_DAY_IN_MS
|
||||||
} = require('./utils');
|
} = require('./utils');
|
||||||
const bytes = require('bytes');
|
const bytes = require('bytes');
|
||||||
|
@ -16,8 +14,6 @@ const storage = new Storage(localStorage);
|
||||||
const $ = require('jquery');
|
const $ = require('jquery');
|
||||||
require('jquery-circle-progress');
|
require('jquery-circle-progress');
|
||||||
|
|
||||||
const Raven = window.Raven;
|
|
||||||
|
|
||||||
if (storage.has('referrer')) {
|
if (storage.has('referrer')) {
|
||||||
window.referrer = storage.referrer;
|
window.referrer = storage.referrer;
|
||||||
storage.remove('referrer');
|
storage.remove('referrer');
|
||||||
|
|
|
@ -79,41 +79,10 @@ function gcmCompliant() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function findMetric(href) {
|
|
||||||
switch (href) {
|
|
||||||
case 'https://www.mozilla.org/':
|
|
||||||
return 'mozilla';
|
|
||||||
case 'https://www.mozilla.org/about/legal':
|
|
||||||
return 'legal';
|
|
||||||
case 'https://testpilot.firefox.com/about':
|
|
||||||
return 'about';
|
|
||||||
case 'https://testpilot.firefox.com/privacy':
|
|
||||||
return 'privacy';
|
|
||||||
case 'https://testpilot.firefox.com/terms':
|
|
||||||
return 'terms';
|
|
||||||
case 'https://www.mozilla.org/privacy/websites/#cookies':
|
|
||||||
return 'cookies';
|
|
||||||
case 'https://github.com/mozilla/send':
|
|
||||||
return 'github';
|
|
||||||
case 'https://twitter.com/FxTestPilot':
|
|
||||||
return 'twitter';
|
|
||||||
case 'https://www.mozilla.org/firefox/new/?scene=2':
|
|
||||||
return 'download-firefox';
|
|
||||||
default:
|
|
||||||
return 'other';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isFile(id) {
|
function isFile(id) {
|
||||||
return /^[0-9a-fA-F]{10}$/.test(id);
|
return /^[0-9a-fA-F]{10}$/.test(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendEvent() {
|
|
||||||
return window.analytics.sendEvent
|
|
||||||
.apply(window.analytics, arguments)
|
|
||||||
.catch(() => 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyToClipboard(str) {
|
function copyToClipboard(str) {
|
||||||
const aux = document.createElement('input');
|
const aux = document.createElement('input');
|
||||||
aux.setAttribute('value', str);
|
aux.setAttribute('value', str);
|
||||||
|
@ -143,8 +112,6 @@ module.exports = {
|
||||||
hexToArray,
|
hexToArray,
|
||||||
notify,
|
notify,
|
||||||
gcmCompliant,
|
gcmCompliant,
|
||||||
findMetric,
|
|
||||||
isFile,
|
isFile,
|
||||||
sendEvent,
|
|
||||||
ONE_DAY_IN_MS
|
ONE_DAY_IN_MS
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,5 +35,5 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a class="send-new" data-l10n-id="sendYourFilesLink" target="_blank"></a>
|
<a class="send-new" data-l10n-id="sendYourFilesLink" href="/"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
<div class="all">
|
<div class="all">
|
||||||
<noscript>
|
<noscript>
|
||||||
<h2>Firefox Send requires JavaScript</h2>
|
<h2>Firefox Send requires JavaScript</h2>
|
||||||
<p><a href="https://github.com/mozilla/send/blob/master/docs/faq.md#why-does-firefox-send-require-javascript" target="_blank" rel="noreferrer noopener">Why does Firefox Send require JavaScript?</a></p>
|
<p><a href="https://github.com/mozilla/send/blob/master/docs/faq.md#why-does-firefox-send-require-javascript" rel="noreferrer noopener">Why does Firefox Send require JavaScript?</a></p>
|
||||||
<p>Please enable JavaScript and try again.</p>
|
<p>Please enable JavaScript and try again.</p>
|
||||||
</noscript>
|
</noscript>
|
||||||
{{{body}}}
|
{{{body}}}
|
||||||
|
@ -44,15 +44,15 @@
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div class="legal-links">
|
<div class="legal-links">
|
||||||
<a href="https://www.mozilla.org" target="_blank"><img class="mozilla-logo" src="/resources/mozilla-logo.svg"/></a>
|
<a href="https://www.mozilla.org" target="_blank"><img class="mozilla-logo" src="/resources/mozilla-logo.svg"/></a>
|
||||||
<a href="https://www.mozilla.org/about/legal" data-l10n-id="footerLinkLegal" target="_blank">Legal</a>
|
<a href="https://www.mozilla.org/about/legal" data-l10n-id="footerLinkLegal">Legal</a>
|
||||||
<a href="https://testpilot.firefox.com/about" data-l10n-id="footerLinkAbout" target="_blank">About Test Pilot</a>
|
<a href="https://testpilot.firefox.com/about" data-l10n-id="footerLinkAbout">About Test Pilot</a>
|
||||||
<a href="/legal" data-l10n-id="footerLinkPrivacy" target="_blank">Privacy</a>
|
<a href="/legal" data-l10n-id="footerLinkPrivacy">Privacy</a>
|
||||||
<a href="/legal" data-l10n-id="footerLinkTerms" target="_blank">Terms</a>
|
<a href="/legal" data-l10n-id="footerLinkTerms">Terms</a>
|
||||||
<a href="https://www.mozilla.org/privacy/websites/#cookies" data-l10n-id="footerLinkCookies" target="_blank">Cookies</a>
|
<a href="https://www.mozilla.org/privacy/websites/#cookies" data-l10n-id="footerLinkCookies">Cookies</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="social-links">
|
<div class="social-links">
|
||||||
<a href="https://github.com/mozilla/send" target="_blank" rel="noreferrer noopener"><img class="github" src="/resources/github-icon.svg"/></a>
|
<a href="https://github.com/mozilla/send" rel="noreferrer noopener"><img class="github" src="/resources/github-icon.svg"/></a>
|
||||||
<a href="https://twitter.com/FxTestPilot" target="_blank" rel="noreferrer noopener"><img class="twitter" src="/resources/twitter-icon.svg"/></a>
|
<a href="https://twitter.com/FxTestPilot" rel="noreferrer noopener"><img class="twitter" src="/resources/twitter-icon.svg"/></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
</a>
|
</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="description" data-l10n-id="notSupportedDetail">Unfortunately this browser does not support the web technology that powers Firefox Send. You’ll need to try another browser. We recommend Firefox!</div>
|
<div class="description" data-l10n-id="notSupportedDetail">Unfortunately this browser does not support the web technology that powers Firefox Send. You’ll need to try another browser. We recommend Firefox!</div>
|
||||||
<div class="description"><a href="https://github.com/mozilla/send/blob/master/docs/faq.md#why-is-my-browser-not-supported" data-l10n-id="notSupportedLink" target="_blank" rel="noopener noreferrer">Why is my browser not supported?</a></div>
|
<div class="description"><a href="https://github.com/mozilla/send/blob/master/docs/faq.md#why-is-my-browser-not-supported" data-l10n-id="notSupportedLink" rel="noopener noreferrer">Why is my browser not supported?</a></div>
|
||||||
<a id="dl-firefox" href="https://www.mozilla.org/firefox/new/?scene=2" target="_blank">
|
<a id="dl-firefox" href="https://www.mozilla.org/firefox/new/?scene=2">
|
||||||
<img src="/resources/firefox_logo-only.svg" class="firefox-logo" alt="Firefox"/>
|
<img src="/resources/firefox_logo-only.svg" class="firefox-logo" alt="Firefox"/>
|
||||||
<div class="unsupported-button-text">Firefox<br>
|
<div class="unsupported-button-text">Firefox<br>
|
||||||
<span data-l10n-id="downloadFirefoxButtonSub">Free Download</span>
|
<span data-l10n-id="downloadFirefoxButtonSub">Free Download</span>
|
||||||
|
|
Loading…
Reference in New Issue