From 1cd89d4d06e3a8f2c221628b19cf26a2c69f5d3f Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 6 Mar 2012 11:24:25 -0800 Subject: Fixing WebGL not available bug --- js/mediators/io-mediator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index e763c67c..65218526 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -150,7 +150,7 @@ exports.IoMediator = Montage.create(Component, { switch (file.mode) { case 'html': //Copy webGL library if needed - if (file.webgl.length > 0) { + if (file.webgl && file.webgl.length > 0) { for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { //Checking for RDGE library to be available if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { @@ -308,7 +308,7 @@ exports.IoMediator = Montage.create(Component, { } } //Checking for webGL elements in document - if (template.webgl.length) { + if (template.webgl && template.webgl.length) { // var json, matchingtags = [], webgltag, scripts = template.document.content.document.getElementsByTagName('script'); // -- cgit v1.2.3 From c2805e03c84b6e598556fd06d1ede7aaeea7ce9c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 6 Mar 2012 16:17:54 -0800 Subject: Squashed commit FileIO-Build-Candidate into Master Fixing issues with HTML and CSS URLs. Adjusted RegEx logic. Also code a mirror update and undo/redo changes were merged into this request. Signed-off-by: Valerio Virgillito --- js/mediators/io-mediator.js | 163 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 130 insertions(+), 33 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 65218526..097f5975 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -41,9 +41,12 @@ exports.IoMediator = Montage.create(Component, { }, //////////////////////////////////////////////////////////////////// // - appTemplatesUrl: { + getAppTemplatesUrlRegEx: { enumerable: false, - value: new RegExp(chrome.extension.getURL('js/document/templates/montage-html/'), 'gi') + value: function () { + var regex = new RegExp(chrome.extension.getURL('js/document/templates/montage-html').replace(/\//gi, '\\\/'), 'gi'); + return regex; + } }, //////////////////////////////////////////////////////////////////// // @@ -210,35 +213,51 @@ exports.IoMediator = Montage.create(Component, { parseNinjaTemplateToHtml: { enumerable: false, value: function (template) { + var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])); + regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); //Injecting head and body into old document - template.document.content.document.body.innerHTML = template.body; - template.document.content.document.head.innerHTML = template.head; + template.document.content.document.head.innerHTML = template.head.replace(regexRootUrl, ''); + template.document.content.document.body.innerHTML = template.body.replace(regexRootUrl, ''); //Getting all CSS (style or link) tags var styletags = template.document.content.document.getElementsByTagName('style'), - linktags = template.document.content.document.getElementsByTagName('link'); - //Looping through link tags and removing file recreated elements - for (var j in styletags) { - if (styletags[j].getAttribute) { - if(styletags[j].getAttribute('data-ninja-uri') !== null && !styletags[j].getAttribute('data-ninja-template')) {//TODO: Use querySelectorAll - try { - //Checking head first - template.document.content.document.head.removeChild(styletags[j]); - } catch (e) { - try { - //Checking body if not in head - template.document.content.document.body.removeChild(styletags[j]); - } catch (e) { - //Error, not found! - } + linktags = template.document.content.document.getElementsByTagName('link'), + toremovetags = []; + //Getting styles tags to be removed from document + if (styletags.length) { + for (var j=0; j only | css =