aboutsummaryrefslogtreecommitdiff
path: root/js/lib/NJUtils.js
diff options
context:
space:
mode:
authorAnanya Sen2012-02-02 12:37:29 -0800
committerAnanya Sen2012-02-02 12:37:29 -0800
commit0e595c4e11ce9b44eff157de8616ed15fcd5d6fc (patch)
treeaba0df7f15b631345b9c44b6b50884d06b7a803a /js/lib/NJUtils.js
parent87e247e74040b5e80ff40003d233d5317881102a (diff)
downloadninja-0e595c4e11ce9b44eff157de8616ed15fcd5d6fc.tar.gz
refactoring some file names and locations,
change made to maintain only one codemirror div. Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/lib/NJUtils.js')
-rwxr-xr-xjs/lib/NJUtils.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js
index 56c74b3b..960c832f 100755
--- a/js/lib/NJUtils.js
+++ b/js/lib/NJUtils.js
@@ -210,6 +210,43 @@ exports.NJUtils = Object.create(Object.prototype, {
210 path = path.replace(/\\/g,"/"); 210 path = path.replace(/\\/g,"/");
211 return path.substr(path.lastIndexOf('/') + 1); 211 return path.substr(path.lastIndexOf('/') + 1);
212 } 212 }
213 },
214
215 /***
216 * checks for valid uri pattern
217 * also flags if Windows uri pattern and Unix uri patterns are mixed
218 */
219 isValidUri:{
220 value: function(uri){
221 var isWindowsUri=false, isUnixUri=false,status=false;
222 if(uri !== ""){
223 uri = uri.replace(/^\s+|\s+$/g,""); // strip any leading or trailing spaces
224
225 //for local machine folder uri
226 isWindowsUri = /^([a-zA-Z]:)(\\[^<>:"/\\|?*]+)*\\?$/gi.test(uri);
227 isUnixUri = /^(\/)?(\/(?![.])[^/]*)*\/?$/gi.test(uri);//folders beginning with . are hidden on Mac / Unix
228 status = isWindowsUri || isUnixUri;
229 if(isWindowsUri && isUnixUri){status = false;}
230 }
231 return status;
232 }
233 },
234
235 /***
236 * file name validation
237 */
238 isValidFileName:{
239 value: function(fileName){
240 var status = false;
241 if(fileName !== ""){
242 fileName = fileName.replace(/^\s+|\s+$/g,"");
243 status = !(/[/\\]/g.test(fileName));
244 if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden
245 status = !(/^\./g.test(fileName));
246 }
247 }
248 return status;
249 }
213 } 250 }
214 251
215}); 252});