From 7fbda862c62f37d4c67e4d5a619b7e3cffc309ff Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 22 Mar 2012 16:23:40 -0700 Subject: Adding Ninja URL method to io-mediator --- js/mediators/io-mediator.js | 56 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 18a517a5..cbed3a99 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -532,8 +532,6 @@ function loadWebGL (e) {\n\ getUrlfromNinjaUrl: { enumerable: false, value: function (url, fileRootUrl, fileUrl) { - //console.log("Params: ", url, fileRootUrl, fileUrl); - //console.log("Getting: " + url); // if (url.indexOf(fileRootUrl) !== -1) { url = url.replace(new RegExp(fileRootUrl.replace(/\//gi, '\\\/'), 'gi'), ''); @@ -561,13 +559,63 @@ function loadWebGL (e) {\n\ // url = (path+newURL).replace(/\/\//gi, '/'); } - //console.log("Returning: " + url); - //console.log("-----"); // return url; } }, //////////////////////////////////////////////////////////////////// + // + getDocRootUrl: { + value: function () { + return this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); + } + }, + //////////////////////////////////////////////////////////////////// + // + getNinjaPropUrlRedirect: { + enumerable: false, + value: function (prop/* , root */) { + //Checking for property value to not contain a full direct URL + if (!prop.match(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi)) { + //Checking for attributes and type of source + if (prop.indexOf('href') !== -1 || prop.indexOf('src') !== -1) { + //From HTML attribute + //if (root) { + //prop = (root+prop).replace(/"([^"]*)"/gi, this.getNinjaUrlPrepend.bind(this)); + //} else { + prop = prop.replace(/"([^"]*)"/gi, this.getNinjaUrlPrepend.bind(this)); + //} + } else if (prop.indexOf('url') !== -1) { + //From CSS property + //if (root) { + //prop = (root+prop).replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl.bind(this)); + //} else { + prop = prop.replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl.bind(this)); + //} + function cssUrlToNinjaUrl (s) { + if (s !== 'url') { + s = this.getDocRootUrl() + s; + } + return s; + } + } + } + return prop; + } + }, + //////////////////////////////////////////////////////////////////// + // + getNinjaUrlPrepend: { + enumerable: false, + value: function (url) { + if (url.indexOf('data:') !== -1) { + return url; + } else { + return '"'+this.getDocRootUrl()+url.replace(/\"/gi, '')+'"'; + } + } + }, + //////////////////////////////////////////////////////////////////// //Method to return a string from CSS rules (to be saved to a file) getCssFromRules: { enumerable: false, -- cgit v1.2.3 From 7e61ce5aba0c8465595804da21e365baf4d8c15d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 23 Mar 2012 13:22:42 -0700 Subject: Removing m-js components I/O and fix for webGL Removed saving m-js components as new components broke I/O when present. Also made a fix for checking length of webGL array since first item now is non-user data. (That is to be removed) --- js/mediators/io-mediator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index cbed3a99..1efbb8bb 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -348,7 +348,7 @@ exports.IoMediator = Montage.create(Component, { } } //Checking for webGL elements in document - if (template.webgl && template.webgl.length > 0) { + if (template.webgl && template.webgl.length > 1) {//TODO: Should be length 0, hack for a temp fix var rdgeDirName, rdgeVersion; //Copy webGL library if needed for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { -- cgit v1.2.3