From 29e24f556c72ee56ab7b7ad21ef0b92f7405bfb0 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 29 Mar 2016 12:13:57 +0200 Subject: [PATCH] kill another window variable --- www/_socket/main.js | 12 ++++++++++-- www/_socket/realtime-input.js | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/www/_socket/main.js b/www/_socket/main.js index 1dc106ed4..9c18eeca8 100644 --- a/www/_socket/main.js +++ b/www/_socket/main.js @@ -232,8 +232,16 @@ define([ var rti = module.realtimeInput = realtimeInput.start(realtimeOptions); - // FIXME Spaghetti code. realtime-input needs access to this variable.. - var propogate = window.cryptpad_propogate = function () { + /* + It's incredibly important that you assign 'rti.onLocal' + It's used inside of realtimeInput to make sure that all changes + make it into chainpad. + + It's being assigned this way because it can't be passed in, and + and can't be easily returned from realtime input without making + the code less extensible. + */ + var propogate = rti.onLocal = function () { var shjson = JSON.stringify(Hyperjson.fromDOM(inner, isNotMagicLine)); if (!rti.patchText(shjson)) { return; } rti.onEvent(shjson); diff --git a/www/_socket/realtime-input.js b/www/_socket/realtime-input.js index 4208bc805..06caa1c5d 100644 --- a/www/_socket/realtime-input.js +++ b/www/_socket/realtime-input.js @@ -224,8 +224,9 @@ define([ verbose(message); allMessages.push(message); if (!initializing) { - // FIXME this is out of sync with the application logic - window.cryptpad_propogate(); + if (toReturn.onLocal) { + toReturn.onLocal(); + } } realtime.message(message); });