mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(cloudfunc) add format
This commit is contained in:
parent
cf0059fa2e
commit
aa0d7ffa26
4 changed files with 19 additions and 16 deletions
|
|
@ -138,7 +138,7 @@ var Util, DOM, CloudFunc, CloudCmd;
|
|||
};
|
||||
|
||||
CloudCmd.route = function(pPath){
|
||||
var lQuery, lModule, lFile, lCurrent;
|
||||
var lQuery, lModule, lFile, lCurrent, lMsg;
|
||||
|
||||
if (pPath.length > 0) {
|
||||
lQuery = pPath.split('/');
|
||||
|
|
@ -147,9 +147,10 @@ var Util, DOM, CloudFunc, CloudCmd;
|
|||
lModule = Util.getStrBigFirst(lQuery[1]);
|
||||
lFile = lQuery[2];
|
||||
lCurrent = DOM.getCurrentFileByName(lFile);
|
||||
if (lFile && !lCurrent)
|
||||
Util.log('set current file: error("' + lFile + '")');
|
||||
else {
|
||||
if (lFile && !lCurrent) {
|
||||
lMsg = CloudFunc.format('set current file', lFile, 'error');
|
||||
Util.log(lMsg);
|
||||
} else {
|
||||
DOM.setCurrentFile(lCurrent);
|
||||
CloudCmd.execFromModule(lModule, 'show');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
var CloudCmd, Util, DOM, JsDiff, ace;
|
||||
(function(CloudCmd, Util, DOM){
|
||||
var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace;
|
||||
(function(CloudCmd, Util, DOM, CloudFunc){
|
||||
'use strict';
|
||||
|
||||
CloudCmd.Edit = new EditProto(CloudCmd, Util, DOM);
|
||||
CloudCmd.Edit = new EditProto(CloudCmd, Util, DOM, CloudFunc);
|
||||
|
||||
function EditProto(CloudCmd, Util, DOM){
|
||||
function EditProto(CloudCmd, Util, DOM, CloudFunc){
|
||||
var Name = 'Edit',
|
||||
Loading = false,
|
||||
DIR = CloudCmd.LIBDIRCLIENT + 'edit/',
|
||||
|
|
@ -122,12 +122,7 @@ var CloudCmd, Util, DOM, JsDiff, ace;
|
|||
var lPath = DOM.getCurrentPath(),
|
||||
lValue = Ace.getValue();
|
||||
|
||||
DOM.RESTfull.save(lPath, lValue, function() {
|
||||
var name = DOM.getCurrentName(),
|
||||
msg = 'save: ok("' + name + '")';
|
||||
|
||||
Edit.showMessage(msg);
|
||||
});
|
||||
DOM.RESTfull.save(lPath, lValue, Edit.showMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -192,4 +187,4 @@ var CloudCmd, Util, DOM, JsDiff, ace;
|
|||
};
|
||||
}
|
||||
|
||||
})(CloudCmd, Util, DOM);
|
||||
})(CloudCmd, Util, DOM, CloudFunc);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,12 @@ var Util, exports, CloudFunc = {};
|
|||
CloudFunc.LEFTPANEL = 'left';
|
||||
CloudFunc.RIGHTPANEL = 'right';
|
||||
|
||||
CloudFunc.formatMsg = function(pMsg, pName, pStatus) {
|
||||
var status = pStatus || 'ok';
|
||||
msg = pMsg + ': ' + status + '("' + pName + '")';
|
||||
|
||||
return msg;
|
||||
};
|
||||
/**
|
||||
* Функция убирает последний слеш,
|
||||
* если он - последний символ строки
|
||||
|
|
|
|||
|
|
@ -382,7 +382,8 @@
|
|||
}
|
||||
|
||||
function sendMsg(pParams, pMsg, pName) {
|
||||
main.sendResponse(pParams, pMsg + ': ok("' + pName + '")');
|
||||
var msg = CloudFunc.formatMsg(pMsg, pName);
|
||||
main.sendResponse(pParams, msg);
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue