sframe common changes
parent
d1157c4d72
commit
3b5af3ea74
@ -1,23 +1,36 @@
|
||||
define([
|
||||
'jquery',
|
||||
'/bower_components/nthen/index.js',
|
||||
'/common/sframe-chainpad-netflux-inner.js',
|
||||
|
||||
], function ($, CpNfInner) {
|
||||
var common = {};
|
||||
var cpNfInner;
|
||||
'/common/sframe-channel.js'
|
||||
], function (nThen, CpNfInner, SFrameChannel) {
|
||||
|
||||
// Chainpad Netflux Inner
|
||||
common.startRealtime = function (options) {
|
||||
if (cpNfInner) { return cpNfInner; }
|
||||
cpNfInner = CpNfInner.start(options);
|
||||
return cpNfInner;
|
||||
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) {
|
||||
|
||||
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