|
|
@ -2,7 +2,7 @@ define([
|
|
|
|
'jquery',
|
|
|
|
'jquery',
|
|
|
|
'/bower_components/chainpad-crypto/crypto.js',
|
|
|
|
'/bower_components/chainpad-crypto/crypto.js',
|
|
|
|
'/bower_components/chainpad-netflux/chainpad-netflux.js',
|
|
|
|
'/bower_components/chainpad-netflux/chainpad-netflux.js',
|
|
|
|
'/common/toolbar.js',
|
|
|
|
'/common/toolbar2.js',
|
|
|
|
'/common/cryptpad-common.js',
|
|
|
|
'/common/cryptpad-common.js',
|
|
|
|
'/common/visible.js',
|
|
|
|
'/common/visible.js',
|
|
|
|
'/common/notify.js',
|
|
|
|
'/common/notify.js',
|
|
|
@ -24,6 +24,8 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
Cryptpad.addLoadingScreen();
|
|
|
|
Cryptpad.addLoadingScreen();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Title;
|
|
|
|
|
|
|
|
|
|
|
|
var myFile;
|
|
|
|
var myFile;
|
|
|
|
var myDataType;
|
|
|
|
var myDataType;
|
|
|
|
|
|
|
|
|
|
|
@ -68,17 +70,13 @@ define([
|
|
|
|
var uri = ['', 'blob', id.slice(0,2), id].join('/');
|
|
|
|
var uri = ['', 'blob', id.slice(0,2), id].join('/');
|
|
|
|
console.log("encrypted blob is now available as %s", uri);
|
|
|
|
console.log("encrypted blob is now available as %s", uri);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO use cryptpad-common utilities
|
|
|
|
var b64Key = Nacl.util.encodeBase64(key);
|
|
|
|
window.location.hash = [
|
|
|
|
window.location.hash = Cryptpad.getFileHashFromKeys(id, ib64key);
|
|
|
|
'',
|
|
|
|
|
|
|
|
2,
|
|
|
|
|
|
|
|
Cryptpad.hexToBase64(id).replace(/\//g, '-'),
|
|
|
|
|
|
|
|
Nacl.util.encodeBase64(key).replace(/\//g, '-'),
|
|
|
|
|
|
|
|
''
|
|
|
|
|
|
|
|
].join('/');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$form.hide();
|
|
|
|
$form.hide();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
APP.toolbar.addElement(['fileshare'], {});
|
|
|
|
|
|
|
|
|
|
|
|
// check if the uploaded file can be decrypted
|
|
|
|
// check if the uploaded file can be decrypted
|
|
|
|
var newU8 = FileCrypto.joinChunks(chunks);
|
|
|
|
var newU8 = FileCrypto.joinChunks(chunks);
|
|
|
|
FileCrypto.decrypt(newU8, key, function (e, res) {
|
|
|
|
FileCrypto.decrypt(newU8, key, function (e, res) {
|
|
|
@ -88,7 +86,8 @@ define([
|
|
|
|
myDataType = res.metadata.type;
|
|
|
|
myDataType = res.metadata.type;
|
|
|
|
|
|
|
|
|
|
|
|
var defaultName = Cryptpad.getDefaultName(Cryptpad.parsePadUrl(window.location.href));
|
|
|
|
var defaultName = Cryptpad.getDefaultName(Cryptpad.parsePadUrl(window.location.href));
|
|
|
|
APP.updateTitle(title || defaultName);
|
|
|
|
Title.updateTitle(title || defaultName);
|
|
|
|
|
|
|
|
APP.toolbar.title.show();
|
|
|
|
Cryptpad.alert("successfully uploaded: " + title);
|
|
|
|
Cryptpad.alert("successfully uploaded: " + title);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -133,9 +132,6 @@ define([
|
|
|
|
uploadMode = true;
|
|
|
|
uploadMode = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
|
|
|
|
|
|
|
var defaultName = Cryptpad.getDefaultName(parsed);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getTitle = function () {
|
|
|
|
var getTitle = function () {
|
|
|
|
var pad = Cryptpad.getRelativeHref(window.location.href);
|
|
|
|
var pad = Cryptpad.getRelativeHref(window.location.href);
|
|
|
|
var fo = Cryptpad.getStore().getProxy().fo;
|
|
|
|
var fo = Cryptpad.getStore().getProxy().fo;
|
|
|
@ -143,27 +139,6 @@ define([
|
|
|
|
return data ? data.title : undefined;
|
|
|
|
return data ? data.title : undefined;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var updateTitle = APP.updateTitle = function (newTitle) {
|
|
|
|
|
|
|
|
Cryptpad.renamePad(newTitle, function (err, data) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
console.log("Couldn't set pad title");
|
|
|
|
|
|
|
|
console.error(err);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
document.title = newTitle;
|
|
|
|
|
|
|
|
$bar.find('.' + Toolbar.constants.title).find('span.title').text(data);
|
|
|
|
|
|
|
|
$bar.find('.' + Toolbar.constants.title).find('input').val(data);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var suggestName = function () {
|
|
|
|
|
|
|
|
return document.title || getTitle() || '';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var renameCb = function (err, title) {
|
|
|
|
|
|
|
|
document.title = title;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var exportFile = function () {
|
|
|
|
var exportFile = function () {
|
|
|
|
var suggestion = document.title;
|
|
|
|
var suggestion = document.title;
|
|
|
|
Cryptpad.prompt(Messages.exportPrompt,
|
|
|
|
Cryptpad.prompt(Messages.exportPrompt,
|
|
|
@ -174,33 +149,33 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var displayed = ['useradmin', 'newpad', 'limit'];
|
|
|
|
Title = Cryptpad.createTitle({}, function(){}, Cryptpad);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var displayed = ['title', 'useradmin', 'newpad', 'limit'];
|
|
|
|
if (secret && hexFileName) {
|
|
|
|
if (secret && hexFileName) {
|
|
|
|
displayed.push('share');
|
|
|
|
displayed.push('fileshare');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var configTb = {
|
|
|
|
var configTb = {
|
|
|
|
displayed: displayed,
|
|
|
|
displayed: displayed,
|
|
|
|
ifrw: ifrw,
|
|
|
|
ifrw: ifrw,
|
|
|
|
common: Cryptpad,
|
|
|
|
common: Cryptpad,
|
|
|
|
title: {
|
|
|
|
title: Title.getTitleConfig(),
|
|
|
|
onRename: renameCb,
|
|
|
|
hideDisplayName: true,
|
|
|
|
defaultName: defaultName,
|
|
|
|
$container: $bar
|
|
|
|
suggestName: suggestName
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
share: {
|
|
|
|
|
|
|
|
secret: secret,
|
|
|
|
|
|
|
|
channel: hexFileName
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
hideDisplayName: true
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
Toolbar.create($bar, null, null, null, null, configTb);
|
|
|
|
var toolbar = APP.toolbar = Toolbar.create(configTb);
|
|
|
|
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
|
|
|
|
|
|
|
|
|
|
|
Title.setToolbar(toolbar);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (uploadMode) { toolbar.title.hide(); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $rightside = toolbar.$rightside;
|
|
|
|
|
|
|
|
|
|
|
|
var $export = Cryptpad.createButton('export', true, {}, exportFile);
|
|
|
|
var $export = Cryptpad.createButton('export', true, {}, exportFile);
|
|
|
|
$rightside.append($export);
|
|
|
|
$rightside.append($export);
|
|
|
|
|
|
|
|
|
|
|
|
updateTitle(Cryptpad.initialName || getTitle() || defaultName);
|
|
|
|
Title.updateTitle(Cryptpad.initialName || getTitle() || Title.defaultTitle);
|
|
|
|
|
|
|
|
|
|
|
|
if (!uploadMode) {
|
|
|
|
if (!uploadMode) {
|
|
|
|
var src = Cryptpad.getBlobPathFromHex(hexFileName);
|
|
|
|
var src = Cryptpad.getBlobPathFromHex(hexFileName);
|
|
|
@ -219,7 +194,7 @@ define([
|
|
|
|
var title = document.title = data.metadata.name;
|
|
|
|
var title = document.title = data.metadata.name;
|
|
|
|
myFile = data.content;
|
|
|
|
myFile = data.content;
|
|
|
|
myDataType = data.metadata.type;
|
|
|
|
myDataType = data.metadata.type;
|
|
|
|
updateTitle(title || defaultName);
|
|
|
|
Title.updateTitle(title || Title.defaultTitle);
|
|
|
|
Cryptpad.removeLoadingScreen();
|
|
|
|
Cryptpad.removeLoadingScreen();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|