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([ 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);
});
} };
}); });

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

Loading…
Cancel
Save