From 20057acaff58020cee418d2ed32c1efc54435c45 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 23 Oct 2015 18:54:24 -0400 Subject: [PATCH] Add a function to construct diffs from JSON. --- prototype/UI/index.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/prototype/UI/index.html b/prototype/UI/index.html index 9474b9a96..28cc1b0b2 100644 --- a/prototype/UI/index.html +++ b/prototype/UI/index.html @@ -155,6 +155,13 @@ if (this.leaf != null) { return new Syntax(this, transform); } } + function diffFromJSON(json) { + if (json.pure != null) { return new Diff({ pure: new Patch(json.pure) }); } + if (json.roll != null) { + return new Diff({ ranges: json.roll.extract, roll: new Syntax(json.roll.unwrap, function(x) { return diffFromJSON(x); }) }); + } + } + function Diff(json) { if (json.pure != null) { this.pure = new Patch(json.pure);