feature(edit) if on server would be error with diff, try to save without diff

This commit is contained in:
coderaiser 2013-11-18 12:27:41 +00:00
parent 5cecffda00
commit 1ae9256a56

View file

@ -15,6 +15,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
Ace,
Msg,
Key = CloudCmd.Key,
Dialog = DOM.Dialog,
Images = DOM.Images,
Element;
@ -131,12 +132,9 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
query = '?patch';
}
DOM.RESTful.save(lPath, lValue, Edit.showMessage, query);
DOM.RESTful.save(lPath, lValue, onSave, query);
}, function(callback) {
diff(lValue, function(diff) {
Value = lValue;
Util.exec(callback, diff);
});
diff(lValue, callback);
});
});
}
@ -188,6 +186,24 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
}
}
function onSave(text) {
var ret,
isError = Util.isContainStrAtBegin(text, 'error'),
path = DOM.getCurrentPath(),
msg = '\nShould I save file anyway?';
if (!isError)
Edit.showMessage(text);
else {
ret = Dialog.confirm(text + msg);
if (ret) {
DOM.RESTful.save(path, Value, onSave);
Value = Ace.getValue();
}
}
}
this.showMessage = function(text) {
var parent,
TWO_SECONDS = 2000;