Merge branch 'soon'

pull/1/head
yflory 6 years ago
commit 8f16955ced

@ -41,10 +41,34 @@ define([
var Utils = config.modules.Utils; var Utils = config.modules.Utils;
nThen(function (waitFor) { nThen(function (waitFor) {
config.modules.SFrameChannel.create($('#sbox-filePicker-iframe')[0].contentWindow, // The inner iframe tries to get some data from us every ms (cache, store...).
waitFor(function (sfc) { // It will send a "READY" message and wait for our answer with the correct txid.
// First, we have to answer to this message, otherwise we're going to block
// sframe-boot.js. Then we can start the channel.
var msgEv = Utils.Util.mkEvent();
var iframe = $('#sbox-filePicker-iframe')[0].contentWindow;
var postMsg = function (data) {
iframe.postMessage(data, '*');
};
var whenReady = waitFor(function (msg) {
if (msg.source !== iframe) { return; }
var data = JSON.parse(msg.data);
if (!data.txid) { return; }
// Remove the listener once we've received the READY message
window.removeEventListener('message', whenReady);
// Answer with the requested data
postMsg(JSON.stringify({ txid: data.txid, language: Cryptpad.getLanguage() }));
// Then start the channel
window.addEventListener('message', function (msg) {
if (msg.source !== iframe) { return; }
msgEv.fire(msg);
});
config.modules.SFrameChannel.create(msgEv, postMsg, waitFor(function (sfc) {
sframeChan = sfc; sframeChan = sfc;
})); }));
});
window.addEventListener('message', whenReady);
}).nThen(function () { }).nThen(function () {
var updateMeta = function () { var updateMeta = function () {
//console.log('EV_METADATA_UPDATE'); //console.log('EV_METADATA_UPDATE');

Loading…
Cancel
Save