drop.chapril.org-firefoxsend/app/pages/download.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

const html = require('choo/html');
2018-01-30 21:15:09 +01:00
const progress = require('../templates/progress');
const { bytes } = require('../utils');
2018-01-24 19:23:13 +01:00
module.exports = function(state, emit) {
const transfer = state.transfer;
const cancelBtn = html`
<button
id="cancel-upload"
title="${state.translate('deletePopupCancel')}"
onclick=${cancel}>
${state.translate('deletePopupCancel')}
</button>`;
const div = html`
<div id="page-one">
2018-01-16 22:52:09 +01:00
<div id="download">
<div id="download-progress" class="fadeIn">
<div id="dl-title" class="title">
${state.translate('downloadingPageProgress', {
2018-01-16 22:52:09 +01:00
filename: state.fileInfo.name,
size: bytes(state.fileInfo.size)
})}
</div>
<div class="description">
${state.translate('downloadingPageMessage')}
</div>
2018-01-16 22:52:09 +01:00
${progress(transfer.progressRatio)}
<div class="upload">
<div class="progress-text">
${state.translate(transfer.msg, transfer.sizes)}
</div>
${transfer.state === 'downloading' ? cancelBtn : null}
2018-01-16 22:52:09 +01:00
</div>
</div>
</div>
</div>
`;
2018-01-24 19:23:13 +01:00
function cancel() {
const btn = document.getElementById('cancel-upload');
btn.remove();
emit('cancel');
}
return div;
};