Remove cryptpad-common dependency for some inner apps

This commit is contained in:
yflory 2017-11-13 18:09:19 +01:00
parent 1514ad5df3
commit 7cfe64fc5b
16 changed files with 35 additions and 173 deletions

View File

@ -1,7 +1,6 @@
define([
'jquery',
'/bower_components/textpatcher/TextPatcher.js',
'/common/cryptpad-common.js',
'/common/diffMarked.js',
'/bower_components/nthen/index.js',
'/common/sframe-common.js',
@ -9,6 +8,7 @@ define([
'/common/common-util.js',
'/common/common-hash.js',
'/common/modes.js',
'/customize/messages.js',
'cm/lib/codemirror',
'css!cm/lib/codemirror.css',
@ -40,7 +40,6 @@ define([
], function (
$,
TextPatcher,
Cryptpad,
DiffMd,
nThen,
SFCommon,
@ -48,10 +47,10 @@ define([
Util,
Hash,
Modes,
Messages,
CMeditor)
{
window.CodeMirror = CMeditor;
var Messages = Cryptpad.Messages;
var MEDIA_TAG_MODES = Object.freeze([
'markdown',

View File

@ -47,7 +47,6 @@ define([
var userNameKey = common.userNameKey = 'User_name';
var fileHashKey = common.fileHashKey = 'FS_hash';
common.displayNameKey = 'cryptpad.username';
var newPadNameKey = common.newPadNameKey = "newPadName";
var newPadPathKey = common.newPadPathKey = "newPadPath";
common.oldStorageKey = 'CryptPad_RECENTPADS';
common.storageKey = 'filesData';
@ -716,19 +715,6 @@ define([
});
};
var errorHandlers = [];
common.onError = function (h) {
if (typeof h !== "function") { return; }
errorHandlers.push(h);
};
common.storeError = function () {
errorHandlers.forEach(function (h) {
if (typeof h === "function") {
h({type: "store"});
}
});
};
/*
* Buttons
*/
@ -1145,10 +1131,6 @@ define([
return void setTimeout(function () { f(void 0, env); });
}
if (sessionStorage[newPadNameKey]) {
common.initialName = sessionStorage[newPadNameKey];
delete sessionStorage[newPadNameKey];
}
if (sessionStorage[newPadPathKey]) {
common.initialPath = sessionStorage[newPadPathKey];
delete sessionStorage[newPadPathKey];

View File

@ -327,15 +327,6 @@ define([
// Drive already exist: return the existing drive, don't load data from legacy store
onReady(f, rt.proxy, Cryptpad, exp);
})
.on('disconnect', function (info) {
// We only manage errors during the loading screen here. Other websocket errors are handled by the apps
if (info.error) {
if (typeof Cryptpad.storeError === "function") {
Cryptpad.storeError();
}
return;
}
})
.on('change', ['drive', 'migrate'], function () {
var path = arguments[2];
var value = arguments[1];

View File

@ -5,7 +5,6 @@ define([
'/bower_components/chainpad-json-validator/json-ot.js',
'json.sortify',
'/bower_components/textpatcher/TextPatcher.js',
'/common/cryptpad-common.js',
'/bower_components/nthen/index.js',
'/common/sframe-common.js',
'/customize/messages.js',
@ -24,7 +23,6 @@ define([
JsonOT,
JSONSortify,
TextPatcher,
Cryptpad,
nThen,
SFCommon,
Messages,
@ -49,10 +47,6 @@ define([
var badStateTimeout = typeof(AppConfig.badStateTimeout) === 'number' ?
AppConfig.badStateTimeout : 30000;
var onConnectError = function () {
UI.errorLoadingScreen(Messages.websocketError);
};
var create = function (options, cb) {
var evContentUpdate = Util.mkEvent();
var evEditableStateChange = Util.mkEvent();
@ -258,7 +252,7 @@ define([
newContent = normalize(newContent);
contentUpdate(newContent);
} else {
title.updateTitle(Cryptpad.initialName || title.defaultTitle);
title.updateTitle(title.defaultTitle);
evOnDefaultContentNeeded.fire();
}
stateChange(STATE.READY);
@ -441,12 +435,6 @@ define([
}, 2000);
//common.onLogout(function () { ... });
Cryptpad.onError(function (info) {
if (info && info.type === "store") {
onConnectError();
}
});
}).nThen(function (waitFor) {
if (readOnly) { $('body').addClass('cp-readonly'); }
@ -478,7 +466,6 @@ define([
metadataMgr: cpNfInner.metadataMgr,
readOnly: readOnly,
realtime: cpNfInner.chainpad,
common: Cryptpad,
sfCommon: common,
$container: $(toolbarContainer),
$contentContainer: $(contentContainer)

View File

@ -166,14 +166,6 @@ define([
sframeChan.event('EV_LOGOUT');
});
Cryptpad.onError(function (info) {
console.log('error');
console.log(info);
if (info && info.type === "store") {
//onConnectError();
}
});
sframeChan.on('Q_ANON_RPC_MESSAGE', function (data, cb) {
Cryptpad.anonRpcMsg(data.msg, data.content, function (err, response) {
cb({error: err, response: response});

View File

@ -3,12 +3,12 @@ define([
'/bower_components/chainpad-crypto/crypto.js',
'/common/toolbar3.js',
'/bower_components/chainpad-json-validator/json-ot.js',
'/common/cryptpad-common.js',
'/bower_components/nthen/index.js',
'/common/sframe-common.js',
'/common/hyperscript.js',
'/contacts/messenger-ui.js',
'/common/sframe-messenger-inner.js',
'/customize/messages.js',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
@ -18,19 +18,15 @@ define([
Crypto,
Toolbar,
JsonOT,
Cryptpad,
nThen,
SFCommon,
h,
UI,
Messenger
Messenger,
Messages
)
{
var Messages = Cryptpad.Messages;
var APP = {};
var onConnectError = function () {
UI.errorLoadingScreen(Messages.websocketError);
};
var common;
var sFrameChan;
@ -41,12 +37,6 @@ define([
sFrameChan = common.getSframeChannel();
sFrameChan.onReady(waitFor());
}).nThen(function (/*waitFor*/) {
Cryptpad.onError(function (info) {
if (info && info.type === "store") {
onConnectError();
}
});
var toolbarElement = h('div#cp-toolbar.cp-toolbar-container');
document.body.appendChild(toolbarElement);
@ -73,10 +63,8 @@ define([
var displayed = ['useradmin', 'newpad', 'limit', 'pageTitle'];
var configTb = {
displayed: displayed,
common: Cryptpad,
sfCommon: common,
$container: $(toolbarElement),
network: Cryptpad.getNetwork(),
pageTitle: Messages.contacts_title,
metadataMgr: common.getMetadataMgr(),
};

View File

@ -15,6 +15,7 @@ define([
'/common/userObject.js',
'/customize/application_config.js',
'/common/sframe-chainpad-listmap.js',
'/customize/messages.js',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
@ -35,7 +36,8 @@ define([
CommonRealtime,
FO,
AppConfig,
Listmap)
Listmap,
Messages)
{
var Messages = Cryptpad.Messages;
@ -49,10 +51,6 @@ define([
return JSONSortify(obj);
};
var onConnectError = function () {
UI.errorLoadingScreen(Messages.websocketError);
};
var E_OVER_LIMIT = 'E_OVER_LIMIT';
var SEARCH = "search";
@ -1463,7 +1461,7 @@ define([
if (type === 'contacts') { return; }
if (type === 'todo') { return; }
if (type === 'file') { return; }
if (!Cryptpad.isLoggedIn() && AppConfig.registeredOnlyTypes &&
if (!APP.loggedIn && AppConfig.registeredOnlyTypes &&
AppConfig.registeredOnlyTypes.indexOf(type) !== -1) {
return;
}
@ -2961,7 +2959,6 @@ define([
metadataMgr: metadataMgr,
readOnly: readOnly,
realtime: info.realtime,
common: Cryptpad,
sfCommon: common,
$container: APP.$bar
};
@ -3051,12 +3048,6 @@ define([
proxy.on('reconnect', function (info) {
onReconnect(info);
});
Cryptpad.onError(function (info) {
if (info && info.type === "store") {
onConnectError();
}
});
common.onLogout(function () { setEditable(false); });
});
};

View File

@ -3,7 +3,6 @@ define([
'/bower_components/chainpad-crypto/crypto.js',
'/bower_components/textpatcher/TextPatcher.js',
'/bower_components/chainpad-json-validator/json-ot.js',
'/common/cryptpad-common.js',
'/bower_components/nthen/index.js',
'/common/sframe-common.js',
'/common/common-interface.js',
@ -11,6 +10,7 @@ define([
'/common/common-util.js',
'/common/common-hash.js',
'json.sortify',
'/customize/messages.js',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
@ -20,24 +20,16 @@ define([
Crypto,
TextPatcher,
JsonOT,
Cryptpad,
nThen,
SFCommon,
UI,
UIElements,
Util,
Hash,
Sortify)
Sortify,
Messages)
{
var Messages = Cryptpad.Messages;
var APP = window.APP = {
Cryptpad: Cryptpad,
};
var onConnectError = function () {
UI.errorLoadingScreen(Messages.websocketError);
};
var APP = window.APP = {};
var andThen = function (common) {
var metadataMgr = common.getMetadataMgr();
@ -181,11 +173,6 @@ define([
SFCommon.create(waitFor(function (c) { APP.common = common = c; }));
}).nThen(function (/*waitFor*/) {
var metadataMgr = common.getMetadataMgr();
Cryptpad.onError(function (info) {
if (info && info.type === "store") {
onConnectError();
}
});
if (metadataMgr.getMetadataLazy() !== 'uninitialized') {
andThen(common);
return;

View File

@ -94,14 +94,6 @@ define([
sframeChan.onReg('EV_METADATA_UPDATE', updateMeta);
proxy.on('change', 'settings', updateMeta);
Cryptpad.onError(function (info) {
console.log('error');
console.log(info);
if (info && info.type === "store") {
//onConnectError();
}
});
sframeChan.on('Q_ANON_RPC_MESSAGE', function (data, cb) {
Cryptpad.anonRpcMsg(data.msg, data.content, function (err, response) {
cb({error: err, response: response});

View File

@ -2,7 +2,6 @@ define([
'jquery',
'/bower_components/textpatcher/TextPatcher.js',
'/common/toolbar3.js',
'/common/cryptpad-common.js',
'/common/common-util.js',
'/common/cryptget.js',
'/bower_components/nthen/index.js',
@ -16,6 +15,7 @@ define([
'/common/sframe-common-codemirror.js',
'/common/common-thumbnail.js',
'/common/common-interface.js',
'/customize/messages.js',
'cm/lib/codemirror',
'cm/addon/display/placeholder',
@ -32,7 +32,6 @@ define([
$,
TextPatcher,
Toolbar,
Cryptpad,
Util,
Cryptget,
nThen,
@ -46,9 +45,9 @@ define([
SframeCM,
Thumb,
UI,
Messages,
CMeditor)
{
var Messages = Cryptpad.Messages;
var saveAs = window.saveAs;
var APP = window.APP = {
@ -57,7 +56,6 @@ define([
col: []
},
readOnly: false,
Cryptpad: Cryptpad,
mobile: function () { return $('body').width() <= 600; } // Menu and content area are not inline-block anymore for mobiles
};
var Render = Renderer(APP);
@ -332,7 +330,7 @@ define([
/* Any time the realtime object changes, call this function */
var change = function (o, n, path, throttle, cb) {
if (path && !Cryptpad.isArray(path)) {
if (path && !Array.isArray(path)) {
return;
}
if (path && path.join) {
@ -1086,7 +1084,6 @@ define([
metadataMgr: metadataMgr,
readOnly: APP.readOnly,
realtime: info.realtime,
common: Cryptpad,
sfCommon: common,
$container: APP.$bar,
$contentContainer: APP.$content

View File

@ -1,5 +1,4 @@
define([
//'/common/cryptpad-common.js',
'jquery',
'/bower_components/hyperjson/hyperjson.js',
'/bower_components/textpatcher/TextPatcher.js',

View File

@ -3,14 +3,15 @@ define([
'/bower_components/chainpad-crypto/crypto.js',
'/common/sframe-chainpad-listmap.js',
'/common/toolbar3.js',
'/common/cryptpad-common.js',
'/bower_components/nthen/index.js',
'/common/sframe-common.js',
'/common/common-util.js',
'/common/common-interface.js',
'/common/common-realtime.js',
'/customize/messages.js',
'/bower_components/marked/marked.min.js',
'cm/lib/codemirror',
'cm/mode/markdown/markdown',
'css!/bower_components/codemirror/lib/codemirror.css',
@ -24,24 +25,19 @@ define([
Crypto,
Listmap,
Toolbar,
Cryptpad,
nThen,
SFCommon,
Util,
UI,
Realtime,
Messages,
Marked,
CodeMirror
)
{
var Messages = Cryptpad.Messages;
var APP = window.APP = {
Cryptpad: Cryptpad,
_onRefresh: []
};
var onConnectError = function () {
UI.errorLoadingScreen(Messages.websocketError);
};
// Decryption event for avatar mediatag (TODO not needed anymore?)
$(window.document).on('decryption', function (e) {
@ -147,7 +143,7 @@ define([
var addCreateInviteLinkButton = function ($container) {
return;
var obj = APP.lm.proxy;
/*var obj = APP.lm.proxy;
var proxy = Cryptpad.getProxy();
var userViewHash = Util.find(proxy, ['profile', 'view']);
@ -185,7 +181,7 @@ define([
// TODO copy invite link to clipboard
}, null, true);
})
.appendTo($container);
.appendTo($container);*/
};
/* jshint ignore:end */
@ -398,13 +394,13 @@ define([
APP.$container.find('#'+CREATE_ID).remove();
var obj = APP.lm && APP.lm.proxy;
if (!APP.readOnly) {
/*if (!APP.readOnly) {
var pubKeys = Cryptpad.getPublicKeys();
if (pubKeys && pubKeys.curve) {
obj.curveKey = pubKeys.curve;
obj.edKey = pubKeys.ed;
}
}
}*/
if (!APP.initialized) {
var $header = $('<div>', {id: HEADER_ID}).appendTo(APP.$rightside);
@ -426,7 +422,6 @@ define([
var displayed = ['useradmin', 'newpad', 'limit', 'pageTitle'];
var configTb = {
displayed: displayed,
common: Cryptpad,
sfCommon: common,
$container: APP.$toolbar,
pageTitle: Messages.profileButton,
@ -447,12 +442,6 @@ define([
sFrameChan = common.getSframeChannel();
sFrameChan.onReady(waitFor());
}).nThen(function (/*waitFor*/) {
Cryptpad.onError(function (info) {
if (info && info.type === "store") {
onConnectError();
}
});
createToolbar();
var metadataMgr = common.getMetadataMgr();
var privateData = metadataMgr.getPrivateData();

View File

@ -1,7 +1,6 @@
define([
'jquery',
'/common/toolbar3.js',
'/common/cryptpad-common.js',
'/bower_components/nthen/index.js',
'/common/sframe-common.js',
'/common/common-interface.js',
@ -16,7 +15,6 @@ define([
], function (
$,
Toolbar,
Cryptpad,
nThen,
SFCommon,
UI,
@ -26,9 +24,7 @@ define([
)
{
var saveAs = window.saveAs;
var APP = window.APP = {
Cryptpad: Cryptpad,
};
var APP = window.APP = {};
var common;
var metadataMgr;
@ -509,7 +505,6 @@ define([
var displayed = ['useradmin', 'newpad', 'limit', 'pageTitle'];
var configTb = {
displayed: displayed,
common: Cryptpad,
sfCommon: common,
$container: APP.$toolbar,
pageTitle: Messages.settings_title,

View File

@ -1,7 +1,6 @@
define([
'jquery',
'json.sortify',
'/common/cryptpad-common.js',
'/bower_components/nthen/index.js',
'/common/sframe-common.js',
'/slide/slide.js',
@ -9,6 +8,7 @@ define([
'/common/common-util.js',
'/common/common-hash.js',
'/common/common-interface.js',
'/customize/messages.js',
'cm/lib/codemirror',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
@ -44,7 +44,6 @@ define([
], function (
$,
JSONSortify,
Cryptpad,
nThen,
SFCommon,
Slide,
@ -52,10 +51,10 @@ define([
Util,
Hash,
UI,
Messages,
CMeditor)
{
window.CodeMirror = CMeditor;
var Messages = Cryptpad.Messages;
var SLIDE_BACKCOLOR_ID = "cp-app-slide-toolbar-backcolor";
var SLIDE_COLOR_ID = "cp-app-slide-toolbar-color";

View File

@ -3,12 +3,12 @@ define([
'/bower_components/chainpad-crypto/crypto.js',
'/common/sframe-chainpad-listmap.js',
'/common/toolbar3.js',
'/common/cryptpad-common.js',
'/bower_components/nthen/index.js',
'/common/sframe-common.js',
'/common/common-interface.js',
'/common/common-hash.js',
'/todo/todo.js',
'/customize/messages.js',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
@ -18,19 +18,15 @@ define([
Crypto,
Listmap,
Toolbar,
Cryptpad,
nThen,
SFCommon,
Hash,
UI,
Todo
Todo,
Messages
)
{
var Messages = Cryptpad.Messages;
var APP = window.APP = {};
var onConnectError = function () {
UI.errorLoadingScreen(Messages.websocketError);
};
var common;
var sFrameChan;
@ -41,12 +37,6 @@ define([
sFrameChan = common.getSframeChannel();
sFrameChan.onReady(waitFor());
}).nThen(function (/*waitFor*/) {
Cryptpad.onError(function (info) {
if (info && info.type === "store") {
onConnectError();
}
});
var $body = $('body');
var $list = $('#cp-app-todo-taskslist');
@ -206,7 +196,6 @@ define([
var displayed = ['useradmin', 'newpad', 'limit', 'pageTitle'];
var configTb = {
displayed: displayed,
common: Cryptpad,
sfCommon: common,
$container: $bar,
pageTitle: Messages.todo_title,

View File

@ -5,16 +5,14 @@ define([
'/common/toolbar3.js',
'json.sortify',
'/bower_components/chainpad-json-validator/json-ot.js',
'/common/cryptpad-common.js',
'/common/common-util.js',
'/common/cryptget.js',
'/bower_components/nthen/index.js',
'/common/sframe-common.js',
'/common/common-interface.js',
'/api/config',
'/common/common-realtime.js',
'/customize/pages.js',
'/customize/messages.js',
'/customize/application_config.js',
'/common/common-thumbnail.js',
'/whiteboard/colors.js',
@ -32,24 +30,21 @@ define([
Toolbar,
JSONSortify,
JsonOT,
Cryptpad,
Util,
Cryptget,
nThen,
SFCommon,
UI,
ApiConfig,
CommonRealtime,
Pages,
Messages,
AppConfig,
Thumb,
Colors)
{
var saveAs = window.saveAs;
var Messages = Cryptpad.Messages;
var APP = window.APP = {
Cryptpad: Cryptpad,
$: $
};
var Fabric = APP.Fabric = window.fabric;
@ -60,10 +55,6 @@ define([
var toolbar;
var onConnectError = function () {
UI.errorLoadingScreen(Messages.websocketError);
};
var andThen = function (common) {
var config = {};
/* Initialize Fabric */
@ -129,7 +120,7 @@ define([
var updateBrushWidth = function () {
var val = $width.val();
canvas.freeDrawingBrush.width = Number(val);
$widthLabel.text(Cryptpad.Messages._getKey("canvas_widthLabel", [val]));
$widthLabel.text(Messages._getKey("canvas_widthLabel", [val]));
$('#cp-app-whiteboard-width-val').text(val + 'px');
createCursor();
};
@ -140,7 +131,7 @@ define([
var val = $opacity.val();
brush.opacity = Number(val);
canvas.freeDrawingBrush.color = Colors.hex2rgba(brush.color, brush.opacity);
$opacityLabel.text(Cryptpad.Messages._getKey("canvas_opacityLabel", [val]));
$opacityLabel.text(Messages._getKey("canvas_opacityLabel", [val]));
$('#cp-app-whiteboard-opacity-val').text((Number(val) * 100) + '%');
createCursor();
};
@ -409,7 +400,6 @@ define([
metadataMgr: metadataMgr,
readOnly: readOnly,
realtime: info.realtime,
common: Cryptpad,
sfCommon: common,
$container: $bar,
$contentContainer: $('#cp-app-whiteboard-canvas-area')
@ -542,7 +532,7 @@ define([
}
newDoc = hjson.content;
} else {
Title.updateTitle(Cryptpad.initialName || Title.defaultTitle);
Title.updateTitle(Title.defaultTitle);
}
nThen(function (waitFor) {
@ -643,11 +633,6 @@ define([
}));
SFCommon.create(waitFor(function (c) { APP.common = common = c; }));
}).nThen(function (/*waitFor*/) {
Cryptpad.onError(function (info) {
if (info && info.type === "store") {
onConnectError();
}
});
andThen(common);
});
};