diff --git a/lib/client.js b/lib/client.js index 7233d560..2ddf3345 100644 --- a/lib/client.js +++ b/lib/client.js @@ -79,34 +79,40 @@ var Util, DOM, CloudFunc, CloudCmd; * @pParams = {name, path, func, dobefore, arg} */ function loadModule(pParams) { + var lName, lPath, lFunc, lDoBefore, lSlash, lAfterSlash, + isContain; + if (pParams) { - var lName = pParams.name, - lPath = pParams.path, - lFunc = pParams.func, - lDoBefore = pParams.dobefore; + lName = pParams.name, + lPath = pParams.path, + lFunc = pParams.func, + lDoBefore = pParams.dobefore; - if ( Util.isString(pParams) ) + if (Util.isString(pParams)) lPath = pParams; if (lPath && !lName) { lName = Util.getStrBigFirst(lPath); lName = Util.removeStr(lName, '.js'); - var lSlash = lName.indexOf('/'); + lSlash = lName.indexOf('/'); if (lSlash > 0) { - var lAfterSlash = lName.substr(lSlash); + lAfterSlash = lName.substr(lSlash); lName = Util.removeStr(lName, lAfterSlash); } } - if ( !Util.isContainStr(lPath, '.js') ) + isContain = Util.isContainStr(lPath, '.js'); + if (!isContain) lPath += '.js'; if (!CloudCmd[lName]) CloudCmd[lName] = function(pArg) { + var path = CloudCmd.LIBDIRCLIENT + lPath; + Util.exec(lDoBefore); - return DOM.jsload(CloudCmd.LIBDIRCLIENT + lPath, lFunc || + return DOM.jsload(path, lFunc || function() { var Proto = CloudCmd[lName];