From 7a53ed96ed5b6c439456172335bc51e2f00eb01c Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Thu, 27 Jul 2017 10:01:39 -0700 Subject: [PATCH] moved back to common --- frontend/src/common.js | 23 ++++++++++++++++++++++- frontend/src/download.js | 19 ------------------- frontend/src/upload.js | 20 -------------------- 3 files changed, 22 insertions(+), 40 deletions(-) diff --git a/frontend/src/common.js b/frontend/src/common.js index 27e9e5fa..bd49f149 100644 --- a/frontend/src/common.js +++ b/frontend/src/common.js @@ -8,4 +8,25 @@ window.analytics = new testPilotGA({ an: 'Firefox Send', ds: 'web', tid: window.trackerId -}); \ No newline at end of file +}); + +const isSender = location.pathname.includes('/download'); + +gcmCompliant().catch(err => { + $('#page-one').attr('hidden', true); + $('#download').attr('hidden', true); + sendEvent(isSender ? 'sender' : 'recipient', 'unsupported', { + cd6: err + }).then(() => { + location.replace('/unsupported'); + }); +}); + +if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1 && + parseInt(navigator.userAgent.toLowerCase().match(/firefox\/*([^\n\r]*)\./)[1]) <= 49) { + sendEvent(isSender ? 'sender' : 'recipient', 'unsupported', { + cd6: new Error('Firefox is outdated.') + }).then(() => { + location.replace('/unsupported'); + }); +} \ No newline at end of file diff --git a/frontend/src/download.js b/frontend/src/download.js index 2268fc86..224d3731 100644 --- a/frontend/src/download.js +++ b/frontend/src/download.js @@ -8,25 +8,6 @@ const storage = new Storage(localStorage); const $ = require('jquery'); require('jquery-circle-progress'); -gcmCompliant().catch(err => { - $('#page-one').attr('hidden', true); - $('#download').attr('hidden', true); - sendEvent('recipient', 'unsupported', { - cd6: err - }).then(() => { - location.replace('/unsupported'); - }); -}); - -if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1 && - parseInt(navigator.userAgent.toLowerCase().match(/firefox\/*([^\n\r]*)\./)[1]) <= 49) { - sendEvent('recipient', 'unsupported', { - cd6: new Error('Firefox is outdated.') - }).then(() => { - location.replace('/unsupported'); - }); -} - const Raven = window.Raven; $(document).ready(function() { diff --git a/frontend/src/upload.js b/frontend/src/upload.js index 0d283f88..bb1c3f55 100644 --- a/frontend/src/upload.js +++ b/frontend/src/upload.js @@ -11,26 +11,6 @@ const bytes = require('bytes'); const Storage = require('./storage'); const storage = new Storage(localStorage); -gcmCompliant().catch(err => { - $('#page-one').attr('hidden', true); - $('#download').attr('hidden', true); - sendEvent('sender', 'unsupported', { - cd6: err - }).then(() => { - location.replace('/unsupported'); - }); -}); - -if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1 && - parseInt(navigator.userAgent.toLowerCase().match(/firefox\/*([^\n\r]*)\./)[1]) <= 49) { - sendEvent('sender', 'unsupported', { - cd6: new Error('Firefox is outdated.') - }).then(() => { - location.replace('/unsupported'); - }); -} - - const $ = require('jquery'); require('jquery-circle-progress');