From 86028587deff0309b94641227f745a33a2b04b64 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 17 Feb 2014 03:56:43 -0500 Subject: [PATCH] chore(client) route --- lib/client.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/client.js b/lib/client.js index 3e9cccbc..d2f13f53 100644 --- a/lib/client.js +++ b/lib/client.js @@ -156,22 +156,23 @@ var Util, DOM, CloudFunc; Util.ifExec(document.body.scrollIntoViewIfNeeded, lCallBack, lFunc); }; - this.route = function(pPath) { - var lQuery, lModule, lFile, lCurrent, lMsg; + this.route = function(path) { + var query, module, file, current, msg; - if (pPath.length > 0) { - lQuery = pPath.split('/'); + if (path.length > 0) { + query = path.split('/'); - if (lQuery.length > 0) { - lModule = Util.getStrBigFirst(lQuery[1]); - lFile = lQuery[2]; - lCurrent = DOM.getCurrentFileByName(lFile); - if (lFile && !lCurrent) { - lMsg = CloudFunc.formatMsg('set current file', lFile, 'error'); - Util.log(lMsg); + if (query.length > 0) { + module = Util.getStrBigFirst(query[1]); + file = query[2]; + current = DOM.getCurrentFileByName(file); + + if (file && !current) { + msg = CloudFunc.formatMsg('set current file', file, 'error'); + Util.log(msg); } else { - DOM.setCurrentFile(lCurrent); - CloudCmd.execFromModule(lModule, 'show'); + DOM.setCurrentFile(current); + CloudCmd.execFromModule(module, 'show'); } } } @@ -312,7 +313,7 @@ var Util, DOM, CloudFunc; }, function(callback) { - Util.exec(obj, calback); + Util.exec(obj, callback); }); };