|
|
|
@ -1,11 +1,25 @@
|
|
|
|
|
// Load #1, load as little as possible because we are in a race to get the loading screen up.
|
|
|
|
|
define([
|
|
|
|
|
'/bower_components/nthen/index.js',
|
|
|
|
|
'/api/config',
|
|
|
|
|
'jquery',
|
|
|
|
|
'/common/requireconfig.js',
|
|
|
|
|
'/common/cryptget.js'
|
|
|
|
|
], function (ApiConfig, $, RequireConfig, Cryptget) {
|
|
|
|
|
'/common/requireconfig.js'
|
|
|
|
|
], function (nThen, ApiConfig, $, RequireConfig) {
|
|
|
|
|
var requireConfig = RequireConfig();
|
|
|
|
|
$(function () {
|
|
|
|
|
|
|
|
|
|
// Loaded in load #3
|
|
|
|
|
var CpNfOuter;
|
|
|
|
|
var Cryptpad;
|
|
|
|
|
var Crypto;
|
|
|
|
|
var Cryptget;
|
|
|
|
|
|
|
|
|
|
var sframeChan;
|
|
|
|
|
var secret;
|
|
|
|
|
var hashes;
|
|
|
|
|
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
|
$(waitFor());
|
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
|
var req = {
|
|
|
|
|
cfg: requireConfig,
|
|
|
|
|
req: [ '/common/loading.js' ],
|
|
|
|
@ -16,25 +30,38 @@ define([
|
|
|
|
|
$('#sbox-iframe').attr('src',
|
|
|
|
|
ApiConfig.httpSafeOrigin + '/pad2/inner.html?' + requireConfig.urlArgs +
|
|
|
|
|
'#' + encodeURIComponent(JSON.stringify(req)));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// This is a cheap trick to avoid loading sframe-channel in parallel with the
|
|
|
|
|
// loading screen setup.
|
|
|
|
|
var done = waitFor();
|
|
|
|
|
var onMsg = function (msg) {
|
|
|
|
|
var data = JSON.parse(msg.data);
|
|
|
|
|
if (data.q !== 'READY') { return; }
|
|
|
|
|
window.removeEventListener('message', onMsg);
|
|
|
|
|
var _done = done;
|
|
|
|
|
done = function () { };
|
|
|
|
|
_done();
|
|
|
|
|
};
|
|
|
|
|
window.addEventListener('message', onMsg);
|
|
|
|
|
|
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
|
// Load #3, the loading screen is up so grab whatever you need...
|
|
|
|
|
require([
|
|
|
|
|
'/common/sframe-channel.js',
|
|
|
|
|
'/common/sframe-chainpad-netflux-outer.js',
|
|
|
|
|
'/bower_components/nthen/index.js',
|
|
|
|
|
'/common/cryptpad-common.js',
|
|
|
|
|
'/bower_components/chainpad-crypto/crypto.js'
|
|
|
|
|
], function (SFrameChannel, CpNfOuter, nThen, Cryptpad, Crypto) {
|
|
|
|
|
var sframeChan;
|
|
|
|
|
var hashes;
|
|
|
|
|
var secret;
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
|
$(waitFor());
|
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
|
'/bower_components/chainpad-crypto/crypto.js',
|
|
|
|
|
'/common/cryptget.js',
|
|
|
|
|
'/common/sframe-channel.js',
|
|
|
|
|
], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, SFrameChannel) {
|
|
|
|
|
CpNfOuter = _CpNfOuter;
|
|
|
|
|
Cryptpad = _Cryptpad;
|
|
|
|
|
Crypto = _Crypto;
|
|
|
|
|
Cryptget = _Cryptget;
|
|
|
|
|
SFrameChannel.create($('#sbox-iframe')[0].contentWindow, waitFor(function (sfc) {
|
|
|
|
|
sframeChan = sfc;
|
|
|
|
|
console.log('sframe initialized');
|
|
|
|
|
}));
|
|
|
|
|
Cryptpad.ready(waitFor());
|
|
|
|
|
}));
|
|
|
|
|
}).nThen(function (waitFor) {
|
|
|
|
|
secret = Cryptpad.getSecrets();
|
|
|
|
|
if (!secret.channel) {
|
|
|
|
@ -194,5 +221,4 @@ define([
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|