58 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-09-18 15:09:01 +02:00
// Load #1, load as little as possible because we are in a race to get the loading screen up.
2017-07-06 18:00:03 +02:00
define([
2017-09-14 12:01:57 +02:00
'/bower_components/nthen/index.js',
2017-09-18 15:09:01 +02:00
'/api/config',
'jquery',
'/common/requireconfig.js',
'/common/sframe-common-outer.js'
], function (nThen, ApiConfig, $, RequireConfig, SFCommonO) {
var requireConfig = RequireConfig();
var addRpc = function (sFrameChan, Cryptpad) {
Cryptpad = Cryptpad;
// protocols must still be declared in sframe-protocol.js
/*
sFrameChan.on('Q_HEY_BUDDY', function (data, cb) {
cb({
error: null,
response: "HEY BUDDY",
});
});
*/
2017-07-06 18:00:03 +02:00
};
2017-09-18 15:09:01 +02:00
// Loaded in load #2
nThen(function (waitFor) {
2017-09-14 12:01:57 +02:00
$(waitFor());
}).nThen(function (waitFor) {
2017-09-18 15:09:01 +02:00
var req = {
cfg: requireConfig,
req: [ '/common/loading.js' ],
pfx: window.location.origin
2017-07-06 18:00:03 +02:00
};
2017-09-18 15:09:01 +02:00
window.rc = requireConfig;
window.apiconf = ApiConfig;
$('#sbox-iframe').attr('src',
ApiConfig.httpSafeOrigin + '/contacts/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*/) {
SFCommonO.start({
noRealtime: true,
addRpc: addRpc,
2017-07-13 17:32:57 +02:00
});
2017-07-06 18:00:03 +02:00
});
});