From 1d7409dd148050e78a9ddb8ef5f46be059122e34 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 11 Apr 2014 09:58:01 -0400 Subject: [PATCH] feature(util) add convertName --- lib/client/menu.js | 5 +---- lib/util.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/client/menu.js b/lib/client/menu.js index 5da680a2..b2b58963 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -98,10 +98,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; */ function getItem(name, callback) { var ret, - icon = name && name.toLowerCase(); - - icon = Util.removeStr(icon, ['(', ')']); - icon = Util.replaceStr(icon, ' ', '-'); + icon = Util.convertName(name); ret = { name : name, diff --git a/lib/util.js b/lib/util.js index 404a0dab..c31da62f 100644 --- a/lib/util.js +++ b/lib/util.js @@ -510,6 +510,20 @@ return lRet; }; + /** + * function convert name: rm: '(, ), -, " "' + * + * @name + * convert + */ + this.convertName = function(name) { + var conv = name && name.toLowerCase(); + + conv = Util.removeStr(conv, ['(', ')']); + conv = Util.replaceStr(conv, ' ', '-'); + + return conv; + }; this.escapeRegExp = function(pStr) { var lRet = pStr,