diff --git a/www/common/loading.js b/www/common/loading.js index a1693d2c1..41c9365ff 100644 --- a/www/common/loading.js +++ b/www/common/loading.js @@ -1,5 +1,5 @@ define([ - 'less!/customize/src/less/cryptpad.less' + 'less!/customize/src/less/loading.less' ], function () { var urlArgs = window.location.href.replace(/^.*\?([^\?]*)$/, function (all, x) { return x; }); var elem = document.createElement('div'); diff --git a/www/common/sframe-boot.js b/www/common/sframe-boot.js index f230373c6..6ed56cfea 100644 --- a/www/common/sframe-boot.js +++ b/www/common/sframe-boot.js @@ -9,11 +9,22 @@ if (req.pfx) { }; } require.config(req.cfg); -if (req.req) { require(req.req, function () { }); } -window.addEventListener('message', function (msg) { +var txid = Math.random().toString(16).replace('0.', ''); +var intr; +var ready = function () { + intr = setInterval(function () { + if (typeof(txid) !== 'string') { return; } + window.parent.postMessage(JSON.stringify({ q: 'READY', txid: txid }), '*'); + }, 1); +}; +if (req.req) { require(req.req, ready); } else { ready(); } +var onReply = function (msg) { var data = JSON.parse(msg.data); - if (data.q !== 'INIT') { return; } - msg.source.postMessage(JSON.stringify({ txid: data.txid, content: 'OK' }), '*'); + if (data.txid !== txid) { return; } + clearInterval(intr); + txid = {}; + window.removeEventListener('message', onReply); require(['/common/sframe-boot2.js'], function () { }); -}); +}; +window.addEventListener('message', onReply); }()); \ No newline at end of file diff --git a/www/common/sframe-channel.js b/www/common/sframe-channel.js index bce9cfdd3..6bfffb028 100644 --- a/www/common/sframe-channel.js +++ b/www/common/sframe-channel.js @@ -105,7 +105,6 @@ define([ insideHandlers.push(content); }, true); - var intr; var txid; window.addEventListener('message', function (msg) { var data = JSON.parse(msg.data); @@ -113,12 +112,8 @@ define([ console.log("DROP Message from unexpected source"); console.log(msg); } else if (!otherWindow) { - if (data.txid !== txid) { - console.log("DROP Message with weird txid"); - return; - } - clearInterval(intr); otherWindow = ow; + ow.postMessage(JSON.stringify({ txid: data.txid }), '*'); cb(chan); } else if (typeof(data.q) === 'string' && handlers[data.q]) { handlers[data.q].forEach(function (f) { @@ -139,17 +134,6 @@ define([ // we're in the sandbox otherWindow = ow; cb(chan); - } else { - require(['/common/requireconfig.js'], function (RequireConfig) { - txid = mkTxid(); - intr = setInterval(function () { - ow.postMessage(JSON.stringify({ - txid: txid, - content: { requireConf: RequireConfig() }, - q: 'INIT' - }), '*'); - }, 1); - }); } }; diff --git a/www/pad2/inner.html b/www/pad2/inner.html index 23aa8b764..0ebef67b2 100644 --- a/www/pad2/inner.html +++ b/www/pad2/inner.html @@ -2,7 +2,7 @@ - +