Remove Crypto from the modules loaded with RequireJS in realtime-input

It now has to be passed in the config in the main JS file
This commit is contained in:
Yann Flory
2016-04-22 14:26:37 +02:00
parent 8ac69ca262
commit d3203d1c2a
2 changed files with 43 additions and 33 deletions

View File

@@ -87,7 +87,6 @@ define([
}
var fixThings = false;
// var key = Crypto.parseKey(window.location.hash.substring(1));
var editor = window.editor = Ckeditor.replace('editor1', {
// https://dev.ckeditor.com/ticket/10907
needsBrFiller: fixThings,
@@ -184,7 +183,6 @@ define([
}
};
var now = function () { return new Date().getTime(); };
var initializing = true;
var userList = {}; // List of pretty name of all users (mapped with their server ID)
@@ -250,12 +248,29 @@ define([
// our encryption key
cryptKey: key,
// method which allows us to get the id of the user
setMyID: setMyID,
// Crypto object to avoid loading it twice in Cryptpad
crypto: Crypto,
// really basic operational transform
transformFunction : JsonOT.validate
};
var updateUserList = function(shjson) {
// Extract the user list (metadata) from the hyperjson
var hjson = JSON.parse(shjson);
var peerUserList = hjson[hjson.length-1];
if(peerUserList.metadata) {
var userData = peerUserList.metadata;
// Update the local user data
addToUserList(userData);
hjson.pop();
}
return hjson;
}
var onRemote = realtimeOptions.onRemote = function (info) {
if (initializing) { return; }
@@ -265,18 +280,7 @@ define([
cursor.update();
// Extract the user list (metadata) from the hyperjson
var hjson = JSON.parse(shjson);
var peerUserList = hjson[hjson.length-1];
if(peerUserList.metadata) {
var userData = peerUserList.metadata;
// Update the local user data
userList = userData;
// Send the new data to the toolbar
if(toolbarList && typeof toolbarList.onChange === "function") {
toolbarList.onChange(userList);
}
hjson.pop();
}
var hjson = updateUserList(shjson);
// build a dom from HJSON, diff, and patch the editor
applyHjson(shjson);