From b21910f2eb5661d66d6f0518f2f3f662a351be8f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 10:38:07 +0000 Subject: [PATCH] feature(edit) add get data from storage before diff --- lib/client/edit.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 991563f8..fcfa903c 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -189,21 +189,28 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; } function diff(pNewValue, pCallBack) { - var libs = [ + var libs = [ LIBDIR + 'diff.js', LIBDIR + 'diff/diff-match-patch.js' ], - url = CloudFunc.getCombineURL(libs); + url = CloudFunc.getCombineURL(libs); DOM.jsload(url, function() { - var patch; + var patch, + isAllowed = DOM.Storage.isAllowed(); if (!Diff) - Diff = new DiffProto(diff_match_patch); + Diff = new DiffProto(diff_match_patch); - patch = Diff.createPatch(Value, pNewValue); - - Util.exec(pCallBack, patch); + Util.ifExec(!isAllowed, function() { + patch = Diff.createPatch(Value, pNewValue); + Util.exec(pCallBack, patch); + }, function(callback) { + DOM.getCurrentData(function(data) { + Value = data.data; + callback(); + }); + }); }); }