const html = require('choo/html'); module.exports = function(state, emit) { const fileInfo = state.fileInfo; const label = fileInfo.password === null ? html` ` : html` `; const div = html`
${label}
`; function inputChanged() { const input = document.getElementById('unlock-input'); const btn = document.getElementById('unlock-btn'); if (input.value.length > 0) { btn.classList.remove('btn-hidden'); input.classList.remove('input-no-btn'); } else { btn.classList.add('btn-hidden'); input.classList.add('input-no-btn'); } } function checkPassword(event) { event.preventDefault(); const password = document.getElementById('unlock-input').value; if (password.length > 0) { document.getElementById('unlock-btn').disabled = true; state.fileInfo.url = window.location.href; state.fileInfo.password = password; emit('preview'); } } return div; };