From 0537c289198f21627997efebe358224d20c6c940 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 13 Apr 2016 13:53:20 +0200 Subject: [PATCH] Add switchable logging to TextPatcher.js --- www/common/TextPatcher.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/www/common/TextPatcher.js b/www/common/TextPatcher.js index 66858826d..ee9c6fb61 100644 --- a/www/common/TextPatcher.js +++ b/www/common/TextPatcher.js @@ -79,14 +79,15 @@ var log = function (text, op) { Due to its reliance on patch, applyChange has side effects on the supplied realtime facade. */ -var applyChange = function(ctx, oldval, newval) { +var applyChange = function(ctx, oldval, newval, logging) { var op = diff(oldval, newval); - // log(oldval, op) + if (logging) { log(oldval, op) } patch(ctx, op); }; var create = function(config) { var ctx = config.realtime; + var logging = config.logging; // initial state will always fail the !== check in genop. // because nothing will equal this object @@ -100,7 +101,7 @@ var create = function(config) { // propogate() return function (newContent) { if (newContent !== content) { - applyChange(ctx, ctx.getUserDoc(), newContent); + applyChange(ctx, ctx.getUserDoc(), newContent, logging); if (ctx.getUserDoc() !== newContent) { console.log("Expected that: `ctx.getUserDoc() === newContent`!"); }