const html = require('choo/html'); const raw = require('choo/html/raw'); const assets = require('../../common/assets'); const REPORTABLES = ['Malware', 'Pii', 'Abuse']; module.exports = function(state, emit) { let submitting = false; const file = state.fileInfo; if (!file) { return html`

${state.translate('reportUnknownDescription')}

`; } if (file.reported) { return html`

${state.translate('reportedTitle')}

${state.translate('reportedDescription')}

${state.translate('okButton')}

`; } return html`

${state.translate('reportFile')}

${state.translate('reportDescription')}

    ${REPORTABLES.map( reportable => html`
  • ` )}
  • ${raw( replaceLinks(state.translate('reportReasonCopyright'), [ 'https://www.mozilla.org/about/legal/report-infringement/' ]) )}
`; function optionChanged(event) { event.stopPropagation(); const button = event.currentTarget.nextElementSibling; button.disabled = false; } function report(event) { event.stopPropagation(); event.preventDefault(); if (submitting) { return; } submitting = true; state.fileInfo.reported = true; const form = event.target; emit('report', { reason: form.reason.value }); } function replaceLinks(str, urls) { let i = 0; const s = str.replace( /([^<]+)<\/a>/g, (m, v) => `${v}` ); return `

${s}

`; } };