aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/document/html-document.js22
1 files changed, 13 insertions, 9 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index a56a7e3c..1e41a797 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -408,10 +408,18 @@ exports.HTMLDocument = Montage.create(TextDocument, {
408 // 408 //
409 if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; 409 if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {};
410 //Inserting user's document into template 410 //Inserting user's document into template
411 this._templateDocument.head.innerHTML = this._userDocument.content.head; 411
412 this._templateDocument.body.innerHTML = this._userDocument.content.body; 412 //TODO: Add logic to parse URLs from head/body
413 //TODO: Use querySelectorAll 413 this._templateDocument.head.innerHTML = (this._userDocument.content.head.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, ninjaUrlRedirect.bind(this))).replace(/url\(([^"]*)(.+?)\1\)/g, ninjaUrlRedirect.bind(this));
414 var scripttags = this._templateDocument.html.getElementsByTagName('script'), webgldata; 414 this._templateDocument.body.innerHTML = (this._userDocument.content.body.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, ninjaUrlRedirect.bind(this))).replace(/url\(([^"]*)(.+?)\1\)/g, ninjaUrlRedirect.bind(this));
415 //
416 function ninjaUrlRedirect (prop) {
417 console.log(prop);
418 return prop;
419 }
420 //
421
422 var scripttags = this._templateDocument.html.getElementsByTagName('script'), webgldata; //TODO: Use querySelectorAll
415 // 423 //
416 for (var w in scripttags) { 424 for (var w in scripttags) {
417 if (scripttags[w].getAttribute) { 425 if (scripttags[w].getAttribute) {
@@ -513,13 +521,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
513 521
514 522
515 //TODO: Fix regEx to have logic for all possible URLs strings (currently prefixing all url()) 523 //TODO: Fix regEx to have logic for all possible URLs strings (currently prefixing all url())
516 prefixUrl = 'url('+fileCouldDirUrl; 524 prefixUrl = 'url('+fileCouldDirUrl; //This should be re-written with better RegEx
517 tag.innerHTML = cssData.content.replace(/url\(/gi, prefixUrl); 525 tag.innerHTML = cssData.content.replace(/url\(/gi, prefixUrl);
518 526
519 //console.log(("http://hello.com, https://google.com").replace(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi, 'hello'))
520
521 //console.log(tag.innerHTML);
522
523 //Looping through DOM to insert style tag at location of link element 527 //Looping through DOM to insert style tag at location of link element
524 query = this._templateDocument.html.querySelectorAll(['link']); 528 query = this._templateDocument.html.querySelectorAll(['link']);
525 for (var j in query) { 529 for (var j in query) {