2017-11-08 00:54:42 +01:00
|
|
|
const html = require('choo/html');
|
2017-12-05 21:45:36 +01:00
|
|
|
/*
|
|
|
|
The current weback config uses package.json to generate
|
|
|
|
version.json for /__version__ meaning `require` returns the
|
|
|
|
string 'version.json' in the frontend context but the json
|
|
|
|
on the server.
|
|
|
|
|
|
|
|
We want `version` to be constant at build time so this file
|
|
|
|
has a custom loader (/build/version_loader.js) just to replace
|
|
|
|
string with the value from package.json. 🤢
|
|
|
|
*/
|
2018-02-13 20:32:59 +01:00
|
|
|
const version = require('../../../package.json').version || 'VERSION';
|
2018-02-16 21:56:53 +01:00
|
|
|
const browser = browserName();
|
|
|
|
|
|
|
|
module.exports = function(state) {
|
2018-02-26 22:49:26 +01:00
|
|
|
const feedbackUrl = `https://qsurvey.mozilla.com/s3/txp-firefox-send?ver=${version}&browser=${browser}`;
|
2018-03-12 18:15:11 +01:00
|
|
|
const header = html`
|
|
|
|
<header class="header">
|
|
|
|
<div class="logo">
|
2018-02-16 21:56:53 +01:00
|
|
|
</div>
|
2018-03-12 18:15:11 +01:00
|
|
|
<a href="${feedbackUrl}"
|
|
|
|
rel="noreferrer noopener"
|
|
|
|
class="feedback"
|
|
|
|
target="_blank">${state.translate('siteFeedback')}</a>
|
|
|
|
</header>`;
|
|
|
|
// HACK
|
|
|
|
// We only want to render this once because we
|
|
|
|
// toggle the targets of the links with utils/openLinksInNewTab
|
|
|
|
header.isSameNode = function(target) {
|
|
|
|
return target && target.nodeName && target.nodeName === 'HEADER';
|
|
|
|
};
|
|
|
|
return header;
|
2018-02-16 21:56:53 +01:00
|
|
|
};
|
2017-11-08 00:54:42 +01:00
|
|
|
|
2018-01-16 22:21:26 +01:00
|
|
|
function browserName() {
|
|
|
|
try {
|
|
|
|
if (/firefox/i.test(navigator.userAgent)) {
|
|
|
|
return 'firefox';
|
|
|
|
}
|
|
|
|
if (/edge/i.test(navigator.userAgent)) {
|
|
|
|
return 'edge';
|
|
|
|
}
|
|
|
|
if (/trident/i.test(navigator.userAgent)) {
|
|
|
|
return 'ie';
|
|
|
|
}
|
|
|
|
if (/chrome/i.test(navigator.userAgent)) {
|
|
|
|
return 'chrome';
|
|
|
|
}
|
|
|
|
if (/safari/i.test(navigator.userAgent)) {
|
|
|
|
return 'safari';
|
|
|
|
}
|
|
|
|
return 'other';
|
|
|
|
} catch (e) {
|
|
|
|
return 'unknown';
|
|
|
|
}
|
|
|
|
}
|