wip
parent
498c8229e9
commit
8b702e0150
@ -0,0 +1,31 @@
|
|||||||
|
define([
|
||||||
|
'less!/customize/src/less/cryptpad.less'
|
||||||
|
], function () {
|
||||||
|
var urlArgs = window.location.href.replace(/^.*\?([^\?]*)$/, function (all, x) { return x; });
|
||||||
|
var elem = document.createElement('div');
|
||||||
|
elem.setAttribute('id', 'loading');
|
||||||
|
elem.innerHTML = [
|
||||||
|
'<div class="loadingContainer">',
|
||||||
|
'<img class="cryptofist" src="/customize/cryptpad-new-logo-colors-logoonly.png?' + urlArgs + '">',
|
||||||
|
'<div class="spinnerContainer">',
|
||||||
|
'<span class="fa fa-circle-o-notch fa-spin fa-4x fa-fw"></span>',
|
||||||
|
'</div>',
|
||||||
|
'<p id="cp-loading-message"></p>',
|
||||||
|
'</div>'
|
||||||
|
].join('');
|
||||||
|
var intr;
|
||||||
|
var append = function () {
|
||||||
|
if (!document.body) { return; }
|
||||||
|
clearInterval(intr);
|
||||||
|
document.body.appendChild(elem);
|
||||||
|
require([
|
||||||
|
'/customize/messages.js',
|
||||||
|
|
||||||
|
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
||||||
|
], function (Messages) {
|
||||||
|
document.getElementById('cp-loading-message').innerText = Messages.loading;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
intr = setInterval(append, 100);
|
||||||
|
append();
|
||||||
|
});
|
@ -1,9 +1,14 @@
|
|||||||
// Stage 0, this gets cached which means we can't change it. boot2-sframe.js is changable.
|
// Stage 0, this gets cached which means we can't change it. boot2-sframe.js is changable.
|
||||||
// Note that this file is meant to be executed only inside of a sandbox iframe.
|
// Note that this file is meant to be executed only inside of a sandbox iframe.
|
||||||
|
;(function () {
|
||||||
window.addEventListener('message', function (msg) {
|
window.addEventListener('message', function (msg) {
|
||||||
var data = JSON.parse(msg.data);
|
var data = JSON.parse(msg.data);
|
||||||
if (data.q !== 'INIT') { return; }
|
if (data.q !== 'INIT') { return; }
|
||||||
msg.source.postMessage(JSON.stringify({ txid: data.txid, content: 'OK' }), '*');
|
msg.source.postMessage(JSON.stringify({ txid: data.txid, content: 'OK' }), '*');
|
||||||
if (data.content && data.content.requireConf) { require.config(data.content.requireConf); }
|
if (data.content && data.content.requireConf) { require.config(data.content.requireConf); }
|
||||||
require(['/common/sframe-boot2.js'], function () { });
|
require(['/common/sframe-boot2.js'], function () { });
|
||||||
});
|
});
|
||||||
|
var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
|
||||||
|
if (req.cfg) { require.config(req.cfg); }
|
||||||
|
if (req.req) { require(req.req, function () { }); }
|
||||||
|
}());
|
@ -1,103 +1,113 @@
|
|||||||
|
|
||||||
define([
|
define([
|
||||||
'/api/config',
|
'/api/config',
|
||||||
'/common/sframe-channel.js',
|
|
||||||
'jquery',
|
'jquery',
|
||||||
'/common/sframe-chainpad-netflux-outer.js',
|
'/common/requireconfig.js'
|
||||||
'/bower_components/nthen/index.js',
|
], function (ApiConfig, $, RequireConfig) {
|
||||||
'/common/cryptpad-common.js',
|
$(function () {
|
||||||
'/bower_components/chainpad-crypto/crypto.js'
|
var req = {
|
||||||
], function (ApiConfig, SFrameChannel, $, CpNfOuter, nThen, Cryptpad, Crypto) {
|
cfg: RequireConfig,
|
||||||
console.log('xxx');
|
req: [ '/common/loading.js' ],
|
||||||
var sframeChan;
|
};
|
||||||
nThen(function (waitFor) {
|
|
||||||
$(waitFor());
|
|
||||||
}).nThen(function (waitFor) {
|
|
||||||
$('#sbox-iframe').attr('src',
|
$('#sbox-iframe').attr('src',
|
||||||
ApiConfig.httpSafeOrigin + '/pad2/inner.html?' + ApiConfig.requireConf.urlArgs);
|
ApiConfig.httpSafeOrigin + '/pad2/inner.html?' + ApiConfig.requireConf.urlArgs +
|
||||||
SFrameChannel.create($('#sbox-iframe')[0].contentWindow, waitFor(function (sfc) {
|
'#' + encodeURIComponent(JSON.stringify(req)));
|
||||||
sframeChan = sfc;
|
});
|
||||||
console.log('sframe initialized');
|
require([
|
||||||
}));
|
'/common/sframe-channel.js',
|
||||||
Cryptpad.ready(waitFor());
|
'/common/sframe-chainpad-netflux-outer.js',
|
||||||
}).nThen(function (waitFor) {
|
'/bower_components/nthen/index.js',
|
||||||
var secret = Cryptpad.getSecrets();
|
'/common/cryptpad-common.js',
|
||||||
var readOnly = secret.keys && !secret.keys.editKeyStr;
|
'/bower_components/chainpad-crypto/crypto.js'
|
||||||
if (!secret.keys) { secret.keys = secret.key; }
|
], function (SFrameChannel, CpNfOuter, nThen, Cryptpad, Crypto) {
|
||||||
|
console.log('xxx');
|
||||||
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
var sframeChan;
|
||||||
parsed.type = parsed.type.replace('pad2', 'pad');
|
nThen(function (waitFor) {
|
||||||
if (!parsed.type) { throw new Error(); }
|
$(waitFor());
|
||||||
var defaultTitle = Cryptpad.getDefaultName(parsed);
|
}).nThen(function (waitFor) {
|
||||||
var updateMeta = function () {
|
SFrameChannel.create($('#sbox-iframe')[0].contentWindow, waitFor(function (sfc) {
|
||||||
//console.log('EV_METADATA_UPDATE');
|
sframeChan = sfc;
|
||||||
var name;
|
console.log('sframe initialized');
|
||||||
nThen(function (waitFor) {
|
}));
|
||||||
Cryptpad.getLastName(waitFor(function (err, n) {
|
Cryptpad.ready(waitFor());
|
||||||
if (err) { console.log(err); }
|
}).nThen(function (waitFor) {
|
||||||
name = n;
|
var secret = Cryptpad.getSecrets();
|
||||||
}));
|
var readOnly = secret.keys && !secret.keys.editKeyStr;
|
||||||
}).nThen(function (waitFor) {
|
if (!secret.keys) { secret.keys = secret.key; }
|
||||||
sframeChan.event('EV_METADATA_UPDATE', {
|
|
||||||
doc: {
|
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||||
defaultTitle: defaultTitle,
|
parsed.type = parsed.type.replace('pad2', 'pad');
|
||||||
type: parsed.type
|
if (!parsed.type) { throw new Error(); }
|
||||||
},
|
var defaultTitle = Cryptpad.getDefaultName(parsed);
|
||||||
user: {
|
var updateMeta = function () {
|
||||||
name: name,
|
//console.log('EV_METADATA_UPDATE');
|
||||||
uid: Cryptpad.getUid(),
|
var name;
|
||||||
avatar: Cryptpad.getAvatarUrl(),
|
nThen(function (waitFor) {
|
||||||
profile: Cryptpad.getProfileUrl(),
|
Cryptpad.getLastName(waitFor(function (err, n) {
|
||||||
curvePublic: Cryptpad.getProxy().curvePublic,
|
if (err) { console.log(err); }
|
||||||
netfluxId: Cryptpad.getNetwork().webChannels[0].myID,
|
name = n;
|
||||||
},
|
}));
|
||||||
priv: {
|
}).nThen(function (waitFor) {
|
||||||
accountName: Cryptpad.getAccountName()
|
sframeChan.event('EV_METADATA_UPDATE', {
|
||||||
}
|
doc: {
|
||||||
|
defaultTitle: defaultTitle,
|
||||||
|
type: parsed.type
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
name: name,
|
||||||
|
uid: Cryptpad.getUid(),
|
||||||
|
avatar: Cryptpad.getAvatarUrl(),
|
||||||
|
profile: Cryptpad.getProfileUrl(),
|
||||||
|
curvePublic: Cryptpad.getProxy().curvePublic,
|
||||||
|
netfluxId: Cryptpad.getNetwork().webChannels[0].myID,
|
||||||
|
},
|
||||||
|
priv: {
|
||||||
|
accountName: Cryptpad.getAccountName()
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
Cryptpad.onDisplayNameChanged(updateMeta);
|
||||||
|
sframeChan.onReg('EV_METADATA_UPDATE', updateMeta);
|
||||||
|
|
||||||
|
Cryptpad.onError(function (info) {
|
||||||
|
console.log('error');
|
||||||
|
console.log(info);
|
||||||
|
if (info && info.type === "store") {
|
||||||
|
//onConnectError();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
|
||||||
Cryptpad.onDisplayNameChanged(updateMeta);
|
|
||||||
sframeChan.onReg('EV_METADATA_UPDATE', updateMeta);
|
|
||||||
|
|
||||||
Cryptpad.onError(function (info) {
|
sframeChan.on('Q_SET_PAD_TITLE_IN_DRIVE', function (newTitle, cb) {
|
||||||
console.log('error');
|
Cryptpad.renamePad(newTitle, undefined, function (err) {
|
||||||
console.log(info);
|
if (err) { cb('ERROR'); } else { cb(); }
|
||||||
if (info && info.type === "store") {
|
});
|
||||||
//onConnectError();
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
sframeChan.on('Q_SET_PAD_TITLE_IN_DRIVE', function (newTitle, cb) {
|
sframeChan.on('Q_SETTINGS_SET_DISPLAY_NAME', function (newName, cb) {
|
||||||
Cryptpad.renamePad(newTitle, undefined, function (err) {
|
Cryptpad.setAttribute('username', newName, function (err) {
|
||||||
if (err) { cb('ERROR'); } else { cb(); }
|
if (err) {
|
||||||
|
console.log("Couldn't set username");
|
||||||
|
console.error(err);
|
||||||
|
cb('ERROR');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Cryptpad.changeDisplayName(newName, true);
|
||||||
|
cb();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
sframeChan.on('Q_SETTINGS_SET_DISPLAY_NAME', function (newName, cb) {
|
CpNfOuter.start({
|
||||||
Cryptpad.setAttribute('username', newName, function (err) {
|
sframeChan: sframeChan,
|
||||||
if (err) {
|
channel: secret.channel,
|
||||||
console.log("Couldn't set username");
|
network: Cryptpad.getNetwork(),
|
||||||
console.error(err);
|
validateKey: secret.keys.validateKey || undefined,
|
||||||
cb('ERROR');
|
readOnly: readOnly,
|
||||||
return;
|
crypto: Crypto.createEncryptor(secret.keys),
|
||||||
|
onConnect: function (wc) {
|
||||||
|
if (readOnly) { return; }
|
||||||
|
Cryptpad.replaceHash(Cryptpad.getEditHashFromKeys(wc.id, secret.keys));
|
||||||
}
|
}
|
||||||
Cryptpad.changeDisplayName(newName, true);
|
|
||||||
cb();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
CpNfOuter.start({
|
|
||||||
sframeChan: sframeChan,
|
|
||||||
channel: secret.channel,
|
|
||||||
network: Cryptpad.getNetwork(),
|
|
||||||
validateKey: secret.keys.validateKey || undefined,
|
|
||||||
readOnly: readOnly,
|
|
||||||
crypto: Crypto.createEncryptor(secret.keys),
|
|
||||||
onConnect: function (wc) {
|
|
||||||
if (readOnly) { return; }
|
|
||||||
Cryptpad.replaceHash(Cryptpad.getEditHashFromKeys(wc.id, secret.keys));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue