mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(edit) add save
This commit is contained in:
parent
a9f60a8d78
commit
a898f53e52
1 changed files with 32 additions and 30 deletions
|
|
@ -143,39 +143,41 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch;
|
|||
Ace.commands.addCommand({
|
||||
name : 'save',
|
||||
bindKey : { win: 'Ctrl-S', mac: 'Command-S' },
|
||||
exec : function () {
|
||||
var lPath = DOM.getCurrentPath(),
|
||||
lValue = Ace.getValue();
|
||||
exec : save
|
||||
});
|
||||
}
|
||||
|
||||
function save () {
|
||||
var lPath = DOM.getCurrentPath(),
|
||||
lValue = Ace.getValue();
|
||||
|
||||
CloudCmd.getConfig(function(config) {
|
||||
var isDiff = config.diff;
|
||||
|
||||
Util.ifExec(!isDiff, function(patch) {
|
||||
var query,
|
||||
isString = Util.isString(patch),
|
||||
length = isString && patch.length < lValue.length;
|
||||
|
||||
CloudCmd.getConfig(function(config) {
|
||||
var isDiff = config.diff;
|
||||
|
||||
Util.ifExec(!isDiff, function(patch) {
|
||||
var query,
|
||||
isString = Util.isString(patch),
|
||||
length = isString && patch.length < lValue.length;
|
||||
Value = lValue;
|
||||
|
||||
if (isString && length) {
|
||||
lValue = patch;
|
||||
query = '?patch';
|
||||
}
|
||||
|
||||
DOM.checkStorageHash(lPath, function(error, equal) {
|
||||
if (!error) {
|
||||
if (!equal)
|
||||
query = '';
|
||||
|
||||
Value = lValue;
|
||||
|
||||
if (isString && length) {
|
||||
lValue = patch;
|
||||
query = '?patch';
|
||||
}
|
||||
|
||||
DOM.checkStorageHash(lPath, function(error, equal) {
|
||||
if (!error) {
|
||||
if (!equal)
|
||||
query = '';
|
||||
|
||||
DOM.RESTful.save(lPath, lValue, onSave, query);
|
||||
}
|
||||
});
|
||||
|
||||
}, function(callback) {
|
||||
diff(lValue, callback);
|
||||
});
|
||||
DOM.RESTful.save(lPath, lValue, onSave, query);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}, function(callback) {
|
||||
diff(lValue, callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue