feature(client) add route

This commit is contained in:
coderaiser 2013-08-23 12:27:12 +00:00
parent ab227efec2
commit 43d8e46fb0

View file

@ -131,6 +131,7 @@ var Util, DOM, CloudFunc, CloudCmd;
CloudCmd.init = function(){
var lCallBack = function(){
Util.loadOnLoad([
Util.retExec(route, location.hash),
initKeysPanel,
initModules,
baseInit
@ -265,10 +266,11 @@ var Util, DOM, CloudFunc, CloudCmd;
Events.add("popstate", function(pEvent) {
var lPath = pEvent.state + '?json';
if(lPath)
ajaxLoad(lPath, {
nohistory: true
});
if (pEvent.state) {
lPath = pEvent.state + '?json';
ajaxLoad(lPath, {nohistory: true});
} else
route(location.hash);
return true;
});
@ -322,6 +324,25 @@ var Util, DOM, CloudFunc, CloudCmd;
CloudCmd.Key();
}
function route(pPath){
var lQuery, lModule, lFile, lCurrent;
if (pPath.length > 0) {
lQuery = pPath.split('/');
if (lQuery.length > 0) {
lModule = Util.getStrBigFirst(lQuery[1]);
lFile = lQuery[2];
lCurrent = DOM.getCurrentFileByName(lFile);
if (lFile && !lCurrent)
Util.log('set current file: error("' + lFile + '")');
else {
DOM.setCurrentFile(lCurrent);
CloudCmd.execFromModule(lModule, 'show');
}
}
}
}
function getSystemFile(pGlobal, pURL){