start to clean up and give things more sensible names.

get rid of the textarea entirely
pull/1/head
ansuz 9 years ago
parent f3fb674504
commit e26246178f

@ -14,28 +14,17 @@
left:0px;
bottom:0px;
right:0px;
width:70%;
width:100%;
height:100%;
border:none;
margin:0;
padding:0;
overflow:hidden;
}
#feedback {
position: fixed;
top: 0px;
right: 0px;
border: 0px;
height: 100vh;
width: 30vw;
background-color: #222;
color: #ccc;
}
</style>
</head>
<body>
<iframe id="pad-iframe" src="inner.html"></iframe>
<textarea id="feedback"></textarea>
</body>
</html>

@ -90,7 +90,7 @@ define([
var $textarea = $('#feedback');
var setEditable = function (bool) {
// inner.style.backgroundColor = bool? 'unset': 'grey';
inner.style.backgroundColor = bool? 'unset': 'grey';
inner.setAttribute('contenteditable', bool);
};
@ -197,7 +197,7 @@ define([
var shjson2 = JSON.stringify(Convert.core.hyperjson.fromDOM(inner));
if (shjson2 !== shjson) {
rti.propogate(shjson2);
rti.patchText(shjson2);
}
};
@ -220,8 +220,8 @@ define([
var onAbort = function (info) {
console.log("Aborting the session!");
// stop the user from continuing to edit
// by setting the editable to false
setEditable(false);
// TODO inform them that the session was torn down
toolbar.failed();
};
@ -246,7 +246,6 @@ define([
// reject patch if it results in invalid JSON
transformFunction : JsonOT.validate,
// websocketURL, ofc
websocketURL: Config.websocketURL,
// username
@ -259,15 +258,16 @@ define([
cryptKey: key.cryptKey
};
var rti = module.realtimeInput = window.rti = realtimeInput.start(realtimeOptions);
var rti = module.realtimeInput = realtimeInput.start(realtimeOptions);
// FIXME Spaghetti code. realtime-input needs access to this variable..
var propogate = window.cryptpad_propogate = function () {
var shjson = JSON.stringify(Convert.core.hyperjson.fromDOM(inner, isNotMagicLine));
if (!rti.propogate(shjson)) { return; }
if (!rti.patchText(shjson)) { return; }
rti.onEvent(shjson);
};
var testInput = window.testInput = function (el, offset) {
var testInput = function (el, offset) {
var i = 0,
j = offset,
input = "The quick red fox jumps over the lazy brown dog. ",

@ -19,10 +19,10 @@ define([
'/bower_components/reconnectingWebsocket/reconnecting-websocket.js',
'/common/crypto.js',
'/_socket/toolbar.js',
'/_socket/sharejs_textarea-transport-only.js',
'/_socket/text-patcher.js',
'/common/chainpad.js',
'/bower_components/jquery/dist/jquery.min.js',
], function (Messages,/*FIXME*/ ReconnectingWebSocket, Crypto, Toolbar, sharejs) {
], function (Messages,/*FIXME*/ ReconnectingWebSocket, Crypto, Toolbar, TextPatcher) {
var $ = window.jQuery;
var ChainPad = window.ChainPad;
var PARANOIA = true;
@ -326,8 +326,7 @@ define([
// TODO maybe push this out to the application layer.
//bindAllEvents(null, doc, onEvent, false);
// TODO rename 'sharejs.attach' to imply what we want to do
var genOp = toReturn.propogate = sharejs.attach({
toReturn.patchText = TextPatcher.create({
realtime: realtime
});

@ -7,9 +7,6 @@ define(function () {
it performs a diff on the two values, and generates patches
which are then passed into `ctx.remove` and `ctx.insert`
*/
var applyChange = function(ctx, oldval, newval) {
// Strings are immutable and have reference equality. I think this test is O(1), so its worth doing.
@ -39,7 +36,7 @@ var applyChange = function(ctx, oldval, newval) {
}
};
var attachTextarea = function(config) {
var create = function(config) {
var ctx = config.realtime;
// initial state will always fail the !== check in genop.
@ -70,5 +67,5 @@ var attachTextarea = function(config) {
};
};
return { attach: attachTextarea };
return { create: create };
});
Loading…
Cancel
Save