aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/document-controller.js9
-rwxr-xr-xjs/document/html-document.js9
2 files changed, 12 insertions, 6 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 64ff2c7e..194496a6 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -76,11 +76,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
76 // 76 //
77 handleWebRequest: { 77 handleWebRequest: {
78 value: function (request) { 78 value: function (request) {
79 if (this._hackRootFlag && request.url.indexOf('js/document/templates/montage-html') !== -1) { 79 //TODO: Check if frameId is proper
80 if (this._hackRootFlag && request.parentFrameId !== -1) {
80 //TODO: Optimize creating string 81 //TODO: Optimize creating string
81 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; 82 //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url);
82 } 83 //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]};
84 return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-html/'))[1]};
83 } 85 }
86 }
84 }, 87 },
85 //////////////////////////////////////////////////////////////////// 88 ////////////////////////////////////////////////////////////////////
86 // 89 //
diff --git a/js/document/html-document.js b/js/document/html-document.js
index e40656a3..1691e3e4 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -486,11 +486,12 @@ exports.HTMLDocument = Montage.create(TextDocument, {
486 if(this._document.styleSheets[i].rules === null) { 486 if(this._document.styleSheets[i].rules === null) {
487 //TODO: Revisit URLs and URI creation logic, very hack right now 487 //TODO: Revisit URLs and URI creation logic, very hack right now
488 var fileUri, cssUrl, cssData, tag, query; 488 var fileUri, cssUrl, cssData, tag, query;
489 if (this._document.styleSheets[i].href.indexOf('js/document/templates/montage-html') !== -1) { 489 //TODO: Parse out relative URLs and map them to absolute
490 if (this._document.styleSheets[i].href.indexOf(chrome.extension.getURL('')) !== -1) {
490 //Getting the url of the CSS file 491 //Getting the url of the CSS file
491 cssUrl = this._document.styleSheets[i].href.split('js/document/templates/montage-html')[1]; 492 cssUrl = this._document.styleSheets[i].href.split('js/document/templates/montage-html')[1];//TODO: Parse out relative URLs and map them to absolute
492 //Creating the URI of the file (this is wrong should not be splitting cssUrl) 493 //Creating the URI of the file (this is wrong should not be splitting cssUrl)
493 fileUri = this.application.ninja.coreIoApi.cloudData.root+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+cssUrl.split('/')[1]; 494 fileUri = this.application.ninja.coreIoApi.cloudData.root+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+cssUrl;
494 //Loading the data from the file 495 //Loading the data from the file
495 cssData = this.application.ninja.coreIoApi.readFile({uri: fileUri}); 496 cssData = this.application.ninja.coreIoApi.readFile({uri: fileUri});
496 //Creating tag with file content 497 //Creating tag with file content
@@ -506,6 +507,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
506 tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value); 507 tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value);
507 } 508 }
508 } 509 }
510 //TODO: Parse out relative URLs and map them to absolute
511 //console.log(cssData.content);
509 tag.innerHTML = cssData.content; 512 tag.innerHTML = cssData.content;
510 //Looping through DOM to insert style tag at location of link element 513 //Looping through DOM to insert style tag at location of link element
511 query = this._templateDocument.html.querySelectorAll(['link']); 514 query = this._templateDocument.html.querySelectorAll(['link']);