Merge branch 'pad2' of github.com:xwiki-labs/cryptpad into pad2

pull/1/head
yflory 7 years ago
commit 25466aa2f9

@ -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);
});
} };
});

@ -14,7 +14,7 @@ define([
'/common/cryptget.js',
'/pad/links.js',
'/bower_components/nthen/index.js',
'/common/sframe-channel.js',
'/common/sframe-common.js',
'/bower_components/file-saver/FileSaver.min.js',
'/bower_components/diff-dom/diffDOM.js',
@ -23,7 +23,7 @@ define([
'less!/customize/src/less/cryptpad.less',
'less!/customize/src/less/toolbar.less'
], function ($, Crypto, CpNfInner, Hyperjson,
Toolbar, Cursor, JsonOT, TypingTest, JSONSortify, TextPatcher, Cryptpad, Cryptget, Links, nThen, SFrameChannel) {
Toolbar, Cursor, JsonOT, TypingTest, JSONSortify, TextPatcher, Cryptpad, Cryptget, Links, nThen, SFCommon) {
var saveAs = window.saveAs;
var Messages = Cryptpad.Messages;
var DiffDom = window.diffDOM;
@ -252,7 +252,7 @@ define([
////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
var andThen = function (editor, Ckeditor, sframeChan) {
var andThen = function (editor, Ckeditor, common) {
//var $iframe = $('#pad-iframe').contents();
//var secret = Cryptpad.getSecrets();
//var readOnly = secret.keys && !secret.keys.editKeyStr;
@ -358,7 +358,6 @@ define([
};
var realtimeOptions = {
sframeChan: sframeChan,
readOnly: readOnly,
// really basic operational transform
transformFunction : JsonOT.validate,
@ -705,7 +704,7 @@ define([
}
};
cpNfInner = CpNfInner.start(realtimeOptions);
cpNfInner = common.startRealtime(realtimeOptions);
Cryptpad.onLogout(function () { setEditable(false); });
@ -748,14 +747,14 @@ define([
var main = function () {
var Ckeditor;
var editor;
var sframeChan;
var common;
nThen(function (waitFor) {
ckEditorAvailable(waitFor(function (ck) { Ckeditor = ck; }));
$(waitFor(function () {
Cryptpad.addLoadingScreen();
}));
SFrameChannel.create(window.top, waitFor(function (sfc) { sframeChan = sfc; }));
SFCommon.create(waitFor(function (c) { common = c; }));
}).nThen(function (waitFor) {
Ckeditor.config.toolbarCanCollapse = true;
if (screen.height < 800) {
@ -775,7 +774,7 @@ define([
onConnectError();
}
});
andThen(editor, Ckeditor, sframeChan);
andThen(editor, Ckeditor, common);
});
};
main();

Loading…
Cancel
Save