diff --git a/lib/client.js b/lib/client.js index 603ba5d1..92ffa10a 100644 --- a/lib/client.js +++ b/lib/client.js @@ -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){