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