cryptpad/www/common/sframe-boot.js

19 lines
809 B
JavaScript
Raw Normal View History

2017-08-07 14:27:57 +00:00
// 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.
2017-08-21 08:34:49 +00:00
;(function () {
var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
2017-08-22 13:50:10 +00:00
req.cfg = req.cfg || {};
if (req.pfx) {
2017-08-22 13:50:10 +00:00
req.cfg.onNodeCreated = function (node, config, module, path) {
node.setAttribute('src', req.pfx + node.getAttribute('src'));
};
}
2017-08-22 13:50:10 +00:00
require.config(req.cfg);
if (req.req) { require(req.req, function () { }); }
2017-08-07 14:27:57 +00:00
window.addEventListener('message', function (msg) {
2017-08-07 15:23:28 +00:00
var data = JSON.parse(msg.data);
2017-08-07 14:27:57 +00:00
if (data.q !== 'INIT') { return; }
2017-08-09 12:45:39 +00:00
msg.source.postMessage(JSON.stringify({ txid: data.txid, content: 'OK' }), '*');
2017-08-07 14:27:57 +00:00
require(['/common/sframe-boot2.js'], function () { });
2017-08-21 08:34:49 +00:00
});
}());