|
|
|
@ -8,6 +8,7 @@ define([
|
|
|
|
|
'/common/common-util.js',
|
|
|
|
|
'/common/common-hash.js',
|
|
|
|
|
'/common/common-interface.js',
|
|
|
|
|
'/common/hyperscript.js',
|
|
|
|
|
'/customize/messages.js',
|
|
|
|
|
|
|
|
|
|
'/file/file-crypto.js',
|
|
|
|
@ -29,6 +30,7 @@ define([
|
|
|
|
|
Util,
|
|
|
|
|
Hash,
|
|
|
|
|
UI,
|
|
|
|
|
h,
|
|
|
|
|
Messages,
|
|
|
|
|
FileCrypto,
|
|
|
|
|
MediaTag)
|
|
|
|
@ -47,8 +49,6 @@ define([
|
|
|
|
|
var $dlform = $('#cp-app-file-download-form');
|
|
|
|
|
var $dlview = $('#cp-app-file-download-view');
|
|
|
|
|
var $label = $form.find('label');
|
|
|
|
|
var $dllabel = $dlform.find('label span');
|
|
|
|
|
var $progress = $('#cp-app-file-dlprogress');
|
|
|
|
|
var $bar = $('.cp-toolbar-container');
|
|
|
|
|
var $body = $('body');
|
|
|
|
|
|
|
|
|
@ -88,6 +88,22 @@ define([
|
|
|
|
|
var toolbar = APP.toolbar = Toolbar.create(configTb);
|
|
|
|
|
|
|
|
|
|
if (!uploadMode) {
|
|
|
|
|
(function () {
|
|
|
|
|
Messages.download = "Download"; // XXX
|
|
|
|
|
Messages.decrypt = "Decrypt"; // XXX
|
|
|
|
|
|
|
|
|
|
var progress = h('div.cp-app-file-progress');
|
|
|
|
|
var progressTxt = h('span.cp-app-file-progress-txt');
|
|
|
|
|
var $progress = $(progress);
|
|
|
|
|
var $progressTxt = $(progressTxt);
|
|
|
|
|
var downloadEl = h('span.cp-app-file-progress-dl', Messages.download);
|
|
|
|
|
var decryptEl = h('span.cp-app-file-progress-dc', Messages.decrypt);
|
|
|
|
|
var progressContainer = h('div.cp-app-file-progress-container', [
|
|
|
|
|
downloadEl,
|
|
|
|
|
decryptEl,
|
|
|
|
|
progress
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
var hexFileName = secret.channel;
|
|
|
|
|
var src = fileHost + Hash.getBlobPathFromHex(hexFileName);
|
|
|
|
|
var key = secret.keys && secret.keys.cryptKey;
|
|
|
|
@ -185,28 +201,41 @@ define([
|
|
|
|
|
cb();
|
|
|
|
|
}
|
|
|
|
|
}).on('progress', function (data) {
|
|
|
|
|
if (data.progress > 75) { return; }
|
|
|
|
|
var p = data.progress +'%';
|
|
|
|
|
$progress.width(p);
|
|
|
|
|
$progressTxt.text(Math.floor(data.progress) + '%');
|
|
|
|
|
}).on('error', function (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// XXX Update "download_button" key to use "download" first and "decrypt" second
|
|
|
|
|
var todoBigFile = function (sizeMb) {
|
|
|
|
|
$dlform.show();
|
|
|
|
|
UI.removeLoadingScreen();
|
|
|
|
|
$dllabel.append($('<br>'));
|
|
|
|
|
$dllabel.append(Util.fixHTML(metadata.name));
|
|
|
|
|
var button = h('button.btn.btn-primary', {
|
|
|
|
|
title: Messages.download_button
|
|
|
|
|
}, Messages.download_button);
|
|
|
|
|
$dlform.append([
|
|
|
|
|
h('h2', Util.fixHTML(metadata.name)),
|
|
|
|
|
h('div.cp-button-container', [
|
|
|
|
|
button,
|
|
|
|
|
progressTxt
|
|
|
|
|
]),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// don't display the size if you don't know it.
|
|
|
|
|
if (typeof(sizeM) === 'number') {
|
|
|
|
|
$dllabel.append($('<br>'));
|
|
|
|
|
$dllabel.append(Messages._getKey('formattedMB', [sizeMb]));
|
|
|
|
|
if (typeof(sizeMb) === 'number') {
|
|
|
|
|
$dlform.find('h2').append(' - ' +
|
|
|
|
|
Messages._getKey('formattedMB', [sizeMb]));
|
|
|
|
|
}
|
|
|
|
|
var decrypting = false;
|
|
|
|
|
var onClick = function (ev) {
|
|
|
|
|
if (decrypting) { return; }
|
|
|
|
|
decrypting = true;
|
|
|
|
|
$(button).prop('disabled', 'disabled');
|
|
|
|
|
$dlform.append(progressContainer);
|
|
|
|
|
displayFile(ev, sizeMb, function (err) {
|
|
|
|
|
$appContainer.css('background-color',
|
|
|
|
|
common.getAppConfig().appBackgroundColor);
|
|
|
|
@ -214,7 +243,7 @@ define([
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
if (typeof(sizeMb) === 'number' && sizeMb < 5) { return void onClick(); }
|
|
|
|
|
$dlform.find('#cp-app-file-dlfile, #cp-app-file-dlprogress').click(onClick);
|
|
|
|
|
$(button).click(onClick);
|
|
|
|
|
};
|
|
|
|
|
common.getFileSize(hexFileName, function (e, data) {
|
|
|
|
|
if (e) {
|
|
|
|
@ -224,6 +253,7 @@ define([
|
|
|
|
|
return void todoBigFile(size);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
})();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|