From 677eca4d7e07c723733567c36bd19e5ad66bbce7 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Jun 2014 05:59:18 -0400 Subject: [PATCH] fix(edit) diff: add error check --- lib/client/edit.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 18c9265c..97467ab1 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -294,26 +294,30 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI ], url = CloudFunc.getJoinURL(libs); - DOM.load.js(url, function() { + DOM.load.js(url, function(error) { var patch, isAllowed = DOM.Storage.isAllowed(); - if (!Diff) - Diff = new DiffProto(diff_match_patch); - - Util.exec.if(!isAllowed, function() { - patch = Diff.createPatch(Value, newValue); - Util.exec(callback, patch); - }, function(func) { - var path = Info.path; + if (error) { + DOM.Dialog.alert(error); + } else { + if (!Diff) + Diff = new DiffProto(diff_match_patch); - DOM.getDataFromStorage(path, function(error, data) { - if (data) - Value = data; + Util.exec.if(!isAllowed, function() { + patch = Diff.createPatch(Value, newValue); + Util.exec(callback, patch); + }, function(func) { + var path = Info.path; - func(); + DOM.getDataFromStorage(path, function(error, data) { + if (data) + Value = data; + + func(); + }); }); - }); + } }); }