From 1d523622bbe8a538a3d13049efac747b60197a17 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 22 May 2014 05:14:53 -0400 Subject: [PATCH] refactor(client) route --- lib/client.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/client.js b/lib/client.js index d2d8f283..8fc741d8 100644 --- a/lib/client.js +++ b/lib/client.js @@ -171,23 +171,21 @@ var Util, DOM, CloudFunc; }; this.route = function(path) { - var query, module, file, current, msg; + var module, file, current, msg, + query = path.split('/'), + length = query.length; - if (path.length > 0) { - query = path.split('/'); + if (length) { + module = Util.getStrBigFirst(query[1]); + file = query[2]; + current = DOM.getCurrentFileByName(file); - 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(current); - CloudCmd.execFromModule(module, 'show'); - } + if (file && !current) { + msg = CloudFunc.formatMsg('set current file', file, 'error'); + Util.log(msg); + } else { + DOM.setCurrentFile(current); + CloudCmd.execFromModule(module, 'show'); } } };