You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cryptpad/www/common/sframe-common.js

37 lines
1.0 KiB
JavaScript

define([
'/bower_components/nthen/index.js',
'/common/sframe-chainpad-netflux-inner.js',
'/common/sframe-channel.js'
], function (nThen, CpNfInner, SFrameChannel) {
// Chainpad Netflux Inner
var funcs = {};
var ctx = {};
funcs.startRealtime = function (options) {
if (ctx.cpNfInner) { return ctx.cpNfInner; }
options.sframeChan = ctx.sframeChan;
ctx.cpNfInner = CpNfInner.start(options);
return ctx.cpNfInner;
};
funcs.isLoggedIn = function () {
if (!ctx.cpNfInner) { throw new Error("cpNfInner is not ready!"); }
return ctx.cpNfInner.metadataMgr.getPrivateData().accountName;
};
funcs.setTitle = function (title /*:string*/, cb) {
};
Object.freeze(funcs);
return { create: function (cb) {
nThen(function (waitFor) {
SFrameChannel.create(window.top, waitFor(function (sfc) { ctx.sframeChan = sfc; }));
// CpNfInner.start() should be here....
}).nThen(function (waitFor) {
cb(funcs);
});
} };
});