|
|
@ -52,7 +52,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------ Trapping Keyboard Events ---------------------- //
|
|
|
|
// ------------------ Trapping Keyboard Events ---------------------- //
|
|
|
|
|
|
|
|
|
|
|
|
var bindEvents = function (element, events, callback, unbind) {
|
|
|
|
var _unused_bindEvents = function (element, events, callback, unbind) {
|
|
|
|
for (var i = 0; i < events.length; i++) {
|
|
|
|
for (var i = 0; i < events.length; i++) {
|
|
|
|
var e = events[i];
|
|
|
|
var e = events[i];
|
|
|
|
if (element.addEventListener) {
|
|
|
|
if (element.addEventListener) {
|
|
|
@ -71,7 +71,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var bindAllEvents = function (textarea, docBody, onEvent, unbind)
|
|
|
|
var _unused_bindAllEvents = function (textarea, docBody, onEvent, unbind)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
we use docBody for the purposes of CKEditor.
|
|
|
|
we use docBody for the purposes of CKEditor.
|
|
|
@ -208,8 +208,10 @@ define([
|
|
|
|
// assert things here...
|
|
|
|
// assert things here...
|
|
|
|
if (realtime.getUserDoc() !== newText) {
|
|
|
|
if (realtime.getUserDoc() !== newText) {
|
|
|
|
// this is a problem
|
|
|
|
// this is a problem
|
|
|
|
// warn("realtime.getUserDoc() !== newText");
|
|
|
|
warn("realtime.getUserDoc() !== newText");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//try{throw new Error();}catch(e){console.log(e.stack);}
|
|
|
|
|
|
|
|
console.log("2: " + realtime.Sha.hex_sha256(realtime.getUserDoc()));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// pass your shiny new realtime into initialization functions
|
|
|
|
// pass your shiny new realtime into initialization functions
|
|
|
@ -255,11 +257,14 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// TODO improve this RegExp such that it allows for more names
|
|
|
|
realtime.onPatch(function () {
|
|
|
|
// right now it only handles names generated by rand64()
|
|
|
|
if (config.onRemote) {
|
|
|
|
var whoami = new RegExp(userName.replace(/[\/\+]/g, function (c) {
|
|
|
|
config.onRemote({
|
|
|
|
return '\\' +c;
|
|
|
|
realtime: realtime
|
|
|
|
}));
|
|
|
|
//realtime.getUserDoc()
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// when you receive a message...
|
|
|
|
// when you receive a message...
|
|
|
|
socket.onMessage.push(function (evt) {
|
|
|
|
socket.onMessage.push(function (evt) {
|
|
|
@ -270,10 +275,11 @@ define([
|
|
|
|
verbose(message);
|
|
|
|
verbose(message);
|
|
|
|
allMessages.push(message);
|
|
|
|
allMessages.push(message);
|
|
|
|
if (!initializing) {
|
|
|
|
if (!initializing) {
|
|
|
|
if (PARANOIA) {
|
|
|
|
// FIXME this is out of sync with the application logic
|
|
|
|
// FIXME this is out of sync with the application logic
|
|
|
|
console.log("xxx");
|
|
|
|
onEvent();
|
|
|
|
window.cryptpad_propogate();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
console.log("init");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
realtime.message(message);
|
|
|
|
realtime.message(message);
|
|
|
|
if (/\[5,/.test(message)) { verbose("pong"); }
|
|
|
|
if (/\[5,/.test(message)) { verbose("pong"); }
|
|
|
@ -281,16 +287,9 @@ define([
|
|
|
|
if (!initializing) {
|
|
|
|
if (!initializing) {
|
|
|
|
if (/\[2,/.test(message)) {
|
|
|
|
if (/\[2,/.test(message)) {
|
|
|
|
//verbose("Got a patch");
|
|
|
|
//verbose("Got a patch");
|
|
|
|
if (whoami.test(message)) {
|
|
|
|
|
|
|
|
//verbose("Received own message");
|
|
|
|
//TODO clean this all up
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//verbose("Received remote message");
|
|
|
|
|
|
|
|
// obviously this is only going to get called if... XXX wat
|
|
|
|
|
|
|
|
if (config.onRemote) { config.onRemote({
|
|
|
|
|
|
|
|
realtime: realtime
|
|
|
|
|
|
|
|
//realtime.getUserDoc()
|
|
|
|
|
|
|
|
}); }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -329,7 +328,7 @@ define([
|
|
|
|
}, 200);
|
|
|
|
}, 200);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO maybe push this out to the application layer.
|
|
|
|
// TODO maybe push this out to the application layer.
|
|
|
|
bindAllEvents(null, doc, onEvent, false);
|
|
|
|
//bindAllEvents(null, doc, onEvent, false);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO rename 'sharejs.attach' to imply what we want to do
|
|
|
|
// TODO rename 'sharejs.attach' to imply what we want to do
|
|
|
|
var genOp = toReturn.propogate = sharejs.attach({
|
|
|
|
var genOp = toReturn.propogate = sharejs.attach({
|
|
|
|