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 6394e3ce..ca1b0886 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -162,15 +162,15 @@ exports.HTMLDocument = Montage.create(TextDocument, {
162 cdm.collectGLData( elt, this._glData ); 162 cdm.collectGLData( elt, this._glData );
163 } 163 }
164 164
165 return this._glData 165 return this._glData;
166 }, 166 },
167 167
168 set: function(value) 168 set: function(value)
169 { 169 {
170 var elt = this.iframe.contentWindow.document.getElementById("UserContent"); 170 var elt = this.documentRoot;
171 if (elt) 171 if (elt)
172 { 172 {
173 console.log( "load canvas data: " + value ); 173 console.log( "load canvas data: " , value );
174 var cdm = new CanvasDataManager(); 174 var cdm = new CanvasDataManager();
175 cdm.loadGLData(elt, value); 175 cdm.loadGLData(elt, value);
176 } 176 }
@@ -374,6 +374,25 @@ exports.HTMLDocument = Montage.create(TextDocument, {
374 //Inserting user's document into template 374 //Inserting user's document into template
375 this._templateDocument.head.innerHTML = this._userDocument.content.head; 375 this._templateDocument.head.innerHTML = this._userDocument.content.head;
376 this._templateDocument.body.innerHTML = this._userDocument.content.body; 376 this._templateDocument.body.innerHTML = this._userDocument.content.body;
377 //TODO: Use querySelectorAll
378 var scripttags = this._templateDocument.html.getElementsByTagName('script'), webgldata;
379 //
380 for (var w in scripttags) {
381 if (scripttags[w].getAttribute) {
382 if (scripttags[w].getAttribute('data-ninja-webgl') !== null) {
383 //TODO: Add logic to handle more than one data tag
384 webgldata = JSON.parse((scripttags[w].innerHTML.replace("(", "")).replace(")", ""));
385 }
386 }
387 }
388 //
389 if (webgldata) {
390 for (var n=0; webgldata.data[n]; n++) {
391 webgldata.data[n] = unescape(webgldata.data[n]);
392 }
393 this._templateDocument.webgl = webgldata.data;
394 }
395
377 396
378 //Adding a handler for the main user document reel to finish loading 397 //Adding a handler for the main user document reel to finish loading
379 this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); 398 this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false);
@@ -487,6 +506,10 @@ exports.HTMLDocument = Montage.create(TextDocument, {
487 506
488 this.callback(this); 507 this.callback(this);
489 508
509 //Setting webGL data
510 if (this._templateDocument.webgl) {
511 this.glData = this._templateDocument.webgl;
512 }
490 } 513 }
491 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 514 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
492 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 515 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////