aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/html-document.js29
1 files changed, 26 insertions, 3 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 8798b407..1901079d 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -177,15 +177,15 @@ exports.HTMLDocument = Montage.create(TextDocument, {
177 cdm.collectGLData( elt, this._glData ); 177 cdm.collectGLData( elt, this._glData );
178 } 178 }
179 179
180 return this._glData 180 return this._glData;
181 }, 181 },
182 182
183 set: function(value) 183 set: function(value)
184 { 184 {
185 var elt = this.iframe.contentWindow.document.getElementById("UserContent"); 185 var elt = this.documentRoot;
186 if (elt) 186 if (elt)
187 { 187 {
188 console.log( "load canvas data: " + value ); 188 console.log( "load canvas data: " , value );
189 var cdm = new CanvasDataManager(); 189 var cdm = new CanvasDataManager();
190 cdm.loadGLData(elt, value); 190 cdm.loadGLData(elt, value);
191 } 191 }
@@ -389,6 +389,25 @@ exports.HTMLDocument = Montage.create(TextDocument, {
389 //Inserting user's document into template 389 //Inserting user's document into template
390 this._templateDocument.head.innerHTML = this._userDocument.content.head; 390 this._templateDocument.head.innerHTML = this._userDocument.content.head;
391 this._templateDocument.body.innerHTML = this._userDocument.content.body; 391 this._templateDocument.body.innerHTML = this._userDocument.content.body;
392 //TODO: Use querySelectorAll
393 var scripttags = this._templateDocument.html.getElementsByTagName('script'), webgldata;
394 //
395 for (var w in scripttags) {
396 if (scripttags[w].getAttribute) {
397 if (scripttags[w].getAttribute('data-ninja-webgl') !== null) {
398 //TODO: Add logic to handle more than one data tag
399 webgldata = JSON.parse((scripttags[w].innerHTML.replace("(", "")).replace(")", ""));
400 }
401 }
402 }
403 //
404 if (webgldata) {
405 for (var n=0; webgldata.data[n]; n++) {
406 webgldata.data[n] = unescape(webgldata.data[n]);
407 }
408 this._templateDocument.webgl = webgldata.data;
409 }
410
392 411
393 //Adding a handler for the main user document reel to finish loading 412 //Adding a handler for the main user document reel to finish loading
394 this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); 413 this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false);
@@ -502,6 +521,10 @@ exports.HTMLDocument = Montage.create(TextDocument, {
502 521
503 this.callback(this); 522 this.callback(this);
504 523
524 //Setting webGL data
525 if (this._templateDocument.webgl) {
526 this.glData = this._templateDocument.webgl;
527 }
505 } 528 }
506 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 529 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
507 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 530 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////