mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
feature(rest) add put patch
This commit is contained in:
parent
d2ba63e050
commit
ee5d3bc7e9
5 changed files with 57 additions and 21 deletions
|
|
@ -116,10 +116,10 @@ var CloudCmd, Util, DOM, CloudFunc;
|
|||
});
|
||||
};
|
||||
|
||||
this.save = function(pUrl, pData, pCallBack){
|
||||
this.save = function(pUrl, pData, pCallBack, pQuery){
|
||||
sendRequest({
|
||||
method : 'PUT',
|
||||
url : CloudFunc.FS + pUrl,
|
||||
url : CloudFunc.FS + pUrl + (pQuery || ''),
|
||||
data : pData,
|
||||
callback : pCallBack,
|
||||
imgPosition : { top: true }
|
||||
|
|
|
|||
|
|
@ -73,10 +73,26 @@ var CloudCmd, Util, DOM, JsDiff, ace;
|
|||
exec : function (pEditor) {
|
||||
var lCurrent = DOM.getCurrentFile(),
|
||||
lPath = DOM.getCurrentPath(lCurrent),
|
||||
lValue = Ace.getValue();
|
||||
lName = DOM.getCurrentName(lCurrent),
|
||||
lValue = Ace.getValue(),
|
||||
lLength = lValue.length;
|
||||
|
||||
DOM.setCurrentSize( lValue.length, lCurrent );
|
||||
DOM.RESTfull.save( lPath, lValue );
|
||||
DOM.setCurrentSize( lLength, lCurrent );
|
||||
|
||||
diff(lName, lValue, function(pDiff) {
|
||||
var lData,
|
||||
lPatch = '',
|
||||
lDiffLength = pDiff.length;
|
||||
|
||||
if (lDiffLength >= lLength)
|
||||
lData = lValue;
|
||||
else {
|
||||
lData = pDiff;
|
||||
lPatch = '?patch';
|
||||
}
|
||||
|
||||
DOM.RESTfull.save( lPath, lData, null, lPatch);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -112,16 +128,13 @@ var CloudCmd, Util, DOM, JsDiff, ace;
|
|||
Ace.moveCursorTo(0, 0);
|
||||
}
|
||||
|
||||
this.diff = function(pName){
|
||||
var lName = DOM.getCurrentName(),
|
||||
lNewValue = Ace.getValue();
|
||||
|
||||
function diff(pName, pNewValue, pCallBack){
|
||||
DOM.jsload('/lib/util/jsdiff/diff.js', function(){
|
||||
var lPatch = JsDiff.createPatch(lName, Value, lNewValue);
|
||||
var lPatch = JsDiff.createPatch(pName, Value, pNewValue);
|
||||
|
||||
Util.log(lPatch);
|
||||
Util.exec(pCallBack, lPatch);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function load(pCallBack){
|
||||
Util.time(Name + ' load');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue