const html = require('choo/html'); module.exports = function(state, emit) { const fileInfo = state.fileInfo; const invalid = fileInfo.password === null; const div = html`

${state.translate('downloadTitle')}

${state.translate('downloadDescription')}

`; if (!(div instanceof String)) { setTimeout(() => document.getElementById('password-input').focus()); } function inputChanged(event) { event.stopPropagation(); event.preventDefault(); const label = document.getElementById('password-error'); const input = document.getElementById('password-input'); const btn = document.getElementById('password-btn'); label.classList.add('invisible'); input.classList.remove('border-red'); btn.classList.remove('bg-red', 'hover:bg-red', 'focus:bg-red'); } function checkPassword(event) { event.stopPropagation(); event.preventDefault(); const el = document.getElementById('password-input'); const password = el.value; if (password.length > 0) { document.getElementById('password-btn').disabled = true; // Strip any url parameters between fileId and secretKey const fileInfoUrl = window.location.href.replace(/\?.+#/, '#'); state.fileInfo.url = fileInfoUrl; state.fileInfo.password = password; emit('getMetadata'); } return false; } return div; };