From 3a754133dbc138390503341fd2e9beba3e43aa4b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 27 Jan 2012 12:05:17 -0800 Subject: Merged old FileIO --- js/lib/NJUtils.js | 0 js/lib/nj-base.js | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 js/lib/NJUtils.js mode change 100644 => 100755 js/lib/nj-base.js (limited to 'js/lib') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js old mode 100644 new mode 100755 diff --git a/js/lib/nj-base.js b/js/lib/nj-base.js old mode 100644 new mode 100755 -- cgit v1.2.3 From 553fce7721cacfd13b6013fdcdd0243c90083b5e Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 1 Feb 2012 11:59:11 -0800 Subject: fixed reference to coreioapi cleaning up opening code view tabs Signed-off-by: Ananya Sen --- js/lib/NJUtils.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/lib') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index d6548871..56c74b3b 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -206,6 +206,8 @@ exports.NJUtils = Object.create(Object.prototype, { ///// Return the last part of a path (e.g. filename) getFileNameFromPath : { value: function(path) { + path = path.replace(/[/\\]$/g,""); + path = path.replace(/\\/g,"/"); return path.substr(path.lastIndexOf('/') + 1); } } -- cgit v1.2.3 From 0e595c4e11ce9b44eff157de8616ed15fcd5d6fc Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 2 Feb 2012 12:37:29 -0800 Subject: refactoring some file names and locations, change made to maintain only one codemirror div. Signed-off-by: Ananya Sen --- js/lib/NJUtils.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'js/lib') 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, { path = path.replace(/\\/g,"/"); return path.substr(path.lastIndexOf('/') + 1); } + }, + + /*** + * checks for valid uri pattern + * also flags if Windows uri pattern and Unix uri patterns are mixed + */ + isValidUri:{ + value: function(uri){ + var isWindowsUri=false, isUnixUri=false,status=false; + if(uri !== ""){ + uri = uri.replace(/^\s+|\s+$/g,""); // strip any leading or trailing spaces + + //for local machine folder uri + isWindowsUri = /^([a-zA-Z]:)(\\[^<>:"/\\|?*]+)*\\?$/gi.test(uri); + isUnixUri = /^(\/)?(\/(?![.])[^/]*)*\/?$/gi.test(uri);//folders beginning with . are hidden on Mac / Unix + status = isWindowsUri || isUnixUri; + if(isWindowsUri && isUnixUri){status = false;} + } + return status; + } + }, + + /*** + * file name validation + */ + isValidFileName:{ + value: function(fileName){ + var status = false; + if(fileName !== ""){ + fileName = fileName.replace(/^\s+|\s+$/g,""); + status = !(/[/\\]/g.test(fileName)); + if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden + status = !(/^\./g.test(fileName)); + } + } + return status; + } } }); -- cgit v1.2.3 From 476a25e8a662270dfe5b37c560e4235f02b146e4 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 2 Feb 2012 12:59:41 -0800 Subject: uri validation moved to file io apis Signed-off-by: Ananya Sen --- js/lib/NJUtils.js | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'js/lib') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 960c832f..74039e64 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -211,27 +211,6 @@ exports.NJUtils = Object.create(Object.prototype, { return path.substr(path.lastIndexOf('/') + 1); } }, - - /*** - * checks for valid uri pattern - * also flags if Windows uri pattern and Unix uri patterns are mixed - */ - isValidUri:{ - value: function(uri){ - var isWindowsUri=false, isUnixUri=false,status=false; - if(uri !== ""){ - uri = uri.replace(/^\s+|\s+$/g,""); // strip any leading or trailing spaces - - //for local machine folder uri - isWindowsUri = /^([a-zA-Z]:)(\\[^<>:"/\\|?*]+)*\\?$/gi.test(uri); - isUnixUri = /^(\/)?(\/(?![.])[^/]*)*\/?$/gi.test(uri);//folders beginning with . are hidden on Mac / Unix - status = isWindowsUri || isUnixUri; - if(isWindowsUri && isUnixUri){status = false;} - } - return status; - } - }, - /*** * file name validation */ -- cgit v1.2.3 From 9e3c10d4e12e896107c8551b4e6fc1dfbaf7bda1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 16 Feb 2012 21:42:18 -0800 Subject: Support for data attributes and adding a random string generator Signed-off-by: Valerio Virgillito --- js/lib/NJUtils.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'js/lib') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 8daafa42..887743c5 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -5,6 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot */ var Montage = require("montage/core/core").Montage, + Uuid = require("montage/core/uuid").Uuid, ElementModel = require("js/models/element-model").ElementModel, Properties3D = require("js/models/properties-3d").Properties3D, ShapeModel = require("js/models/shape-model").ShapeModel, @@ -56,13 +57,18 @@ exports.NJUtils = Object.create(Object.prototype, { ///// Quick "createElement" function "attr" can be classname or object ///// with attribute key/values + ///// Suppor for data attributes make : { value: function(tag, attr) { var el = document.createElement(tag); if (typeof attr === 'object') { for (var a in attr) { if (attr.hasOwnProperty(a)) { - el[a] = attr[a]; + if(a.indexOf("data-") > -1) { + el.setAttribute(a, attr[a]); + } else { + el[a] = attr[a]; + } } } } else if (typeof attr === 'string') { @@ -247,6 +253,20 @@ exports.NJUtils = Object.create(Object.prototype, { } return status; } + }, + + /* ================= misc methods ================= */ + + // Generates an alpha-numeric random number + // len: number of chars + // default length is '8' + generateRandom: { + value: function(len) { + var length; + len ? length = len : length = 8; + + return Uuid.generate().substring(0,length); + } } }); -- cgit v1.2.3