2017-11-07 23:54:42 +00:00
|
|
|
const html = require('choo/html');
|
2018-07-12 20:13:49 +00:00
|
|
|
const version = require('../../../package.json').version;
|
2018-02-16 20:56:53 +00:00
|
|
|
const browser = browserName();
|
|
|
|
|
|
|
|
module.exports = function(state) {
|
2018-02-26 21:49:26 +00:00
|
|
|
const feedbackUrl = `https://qsurvey.mozilla.com/s3/txp-firefox-send?ver=${version}&browser=${browser}`;
|
2018-03-12 17:15:11 +00:00
|
|
|
const header = html`
|
|
|
|
<header class="header">
|
|
|
|
<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 20:56:53 +00:00
|
|
|
};
|
2017-11-07 23:54:42 +00:00
|
|
|
|
2018-01-16 21:21:26 +00: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';
|
|
|
|
}
|
|
|
|
}
|