Use the same code for the different frontend channels

This commit is contained in:
yflory
2019-01-11 15:22:52 +01:00
parent 1e672c4a6b
commit 41a1148c17
3 changed files with 103 additions and 38 deletions

View File

@@ -3,7 +3,7 @@ define([
'/bower_components/nthen/index.js',
'/customize/messages.js',
'/common/sframe-chainpad-netflux-inner.js',
'/common/sframe-channel.js',
'/common/outer/worker-channel.js',
'/common/sframe-common-title.js',
'/common/common-ui-elements.js',
'/common/sframe-common-history.js',
@@ -481,8 +481,16 @@ define([
window.CryptPad_sframe_common = true;
nThen(function (waitFor) {
SFrameChannel.create(window.parent, waitFor(function (sfc) { ctx.sframeChan = sfc; }), true);
// CpNfInner.start() should be here....
var msgEv = Util.mkEvent();
var iframe = window.parent;
window.addEventListener('message', function (msg) {
if (msg.source !== iframe) { return; }
msgEv.fire(msg);
});
var postMsg = function (data) {
iframe.postMessage(data, '*');
};
SFrameChannel.create(msgEv, postMsg, waitFor(function (sfc) { ctx.sframeChan = sfc; }));
}).nThen(function (waitFor) {
localForage.clear();
Language.applyTranslation();