mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-08-04 21:53:14 +00:00
feature(edit) if on server would be error with diff, try to save without diff
This commit is contained in:
parent
5cecffda00
commit
1ae9256a56
1 changed files with 21 additions and 5 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue