Merge branch 'pad2' of github.com:xwiki-labs/cryptpad into pad2
commit
25466aa2f9
@ -1,23 +1,36 @@
|
|||||||
define([
|
define([
|
||||||
'jquery',
|
'/bower_components/nthen/index.js',
|
||||||
'/common/sframe-chainpad-netflux-inner.js',
|
'/common/sframe-chainpad-netflux-inner.js',
|
||||||
|
'/common/sframe-channel.js'
|
||||||
], function ($, CpNfInner) {
|
], function (nThen, CpNfInner, SFrameChannel) {
|
||||||
var common = {};
|
|
||||||
var cpNfInner;
|
|
||||||
|
|
||||||
// Chainpad Netflux Inner
|
// Chainpad Netflux Inner
|
||||||
common.startRealtime = function (options) {
|
var funcs = {};
|
||||||
if (cpNfInner) { return cpNfInner; }
|
var ctx = {};
|
||||||
cpNfInner = CpNfInner.start(options);
|
|
||||||
return cpNfInner;
|
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) {
|
||||||
|
|
||||||
common.isLoggedIn = function () {
|
|
||||||
if (!cpNfInner) { throw new Error("cpNfInner is not ready!"); }
|
|
||||||
return cpNfInner.metadataMgr.getPrivateData().accountName;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return common;
|
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);
|
||||||
|
});
|
||||||
|
} };
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue