aboutsummaryrefslogtreecommitdiff
path: root/js/mediators/io-mediator.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/mediators/io-mediator.js')
-rw-r--r--js/mediators/io-mediator.js38
1 files changed, 33 insertions, 5 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index c22d95be..e9661f20 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -355,13 +355,21 @@ exports.IoMediator = Montage.create(Component, {
355 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { 355 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') {
356 rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name+this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); 356 rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name+this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase();
357 rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; 357 rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version;
358 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.document.root, rdgeDirName); 358 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.document.root, rdgeDirName, hackRename.bind(this));
359 //TODO: Remove, this is copying the library into a static name
360 function hackRename (status) {
361 if (status) {
362 setTimeout(function () {
363 this.application.ninja.coreIoApi.copyDirectory({sourceUri: template.document.root+rdgeDirName, destUri: template.document.root+'assets'});
364 }.bind(this), 3000);
365 }
366 }
359 } else { 367 } else {
360 //TODO: Error handle no available library to copy 368 //TODO: Error handle no available library to copy
361 } 369 }
362 } 370 }
363 // 371 //
364 var json, matchingtags = [], webgltag, scripts = template.document.content.document.getElementsByTagName('script'), webgljstag, webgllibtag; 372 var json, matchingtags = [], webgltag, scripts = template.document.content.document.getElementsByTagName('script'), webgljstag, webgllibtag, webglrdgetag;
365 // 373 //
366 for (var i in scripts) { 374 for (var i in scripts) {
367 if (scripts[i].getAttribute) { 375 if (scripts[i].getAttribute) {
@@ -374,6 +382,9 @@ exports.IoMediator = Montage.create(Component, {
374 if (scripts[i].getAttribute('data-ninja-webgl-lib') !== null) { 382 if (scripts[i].getAttribute('data-ninja-webgl-lib') !== null) {
375 webgllibtag = scripts[i]; // TODO: Add logic to delete unneccesary tags 383 webgllibtag = scripts[i]; // TODO: Add logic to delete unneccesary tags
376 } 384 }
385 if (scripts[i].getAttribute('data-ninja-webgl-rdge') !== null) {
386 webglrdgetag = scripts[i]; // TODO: Add logic to delete unneccesary tags
387 }
377 } 388 }
378 } 389 }
379 // 390 //
@@ -386,10 +397,18 @@ exports.IoMediator = Montage.create(Component, {
386 } 397 }
387 } 398 }
388 // 399 //
400 if (!webglrdgetag) {
401 webglrdgetag = template.document.content.document.createElement('script');
402 webglrdgetag.setAttribute('type', 'text/javascript');
403 webglrdgetag.setAttribute('src', rdgeDirName+'/rdge-compiled.js');
404 webglrdgetag.setAttribute('data-ninja-webgl-rdge', 'true');
405 template.document.content.document.head.appendChild(webglrdgetag);
406 }
407 //
389 if (!webgllibtag) { 408 if (!webgllibtag) {
390 webgllibtag = template.document.content.document.createElement('script'); 409 webgllibtag = template.document.content.document.createElement('script');
391 webgllibtag.setAttribute('type', 'text/javascript'); 410 webgllibtag.setAttribute('type', 'text/javascript');
392 webgllibtag.setAttribute('src', rdgeDirName+'/CanvasDataManager.js'); 411 webgllibtag.setAttribute('src', rdgeDirName+'/CanvasRuntime.js');
393 webgllibtag.setAttribute('data-ninja-webgl-lib', 'true'); 412 webgllibtag.setAttribute('data-ninja-webgl-lib', 'true');
394 template.document.content.document.head.appendChild(webgllibtag); 413 template.document.content.document.head.appendChild(webgllibtag);
395 } 414 }
@@ -421,11 +440,11 @@ function initWebGl (e) {\n\
421 //Creating data manager\n\ 440 //Creating data manager\n\
422 cvsDataMngr = new CanvasDataManager();\n\ 441 cvsDataMngr = new CanvasDataManager();\n\
423 //Loading data to canvas(es)\n\ 442 //Loading data to canvas(es)\n\
424 cvsDataMngr.loadGLData(document.body, ninjaWebGlData, '"+rdgeDirName+"');\n\ 443 cvsDataMngr.loadGLData(document.body, ninjaWebGlData.data, '"+rdgeDirName+"/');\n\
425}\ 444}\
426 "; 445 ";
427 //TODO: Add version and other data for RDGE 446 //TODO: Add version and other data for RDGE
428 json = '\n({\n\t"version": "'+rdgeVersion+'",\n\t"data": ['; 447 json = '\n({\n\t"version": "'+rdgeVersion+'",\n\t"directory": "'+rdgeDirName+'/",\n\t"data": [';
429 //Looping through data to create escaped array 448 //Looping through data to create escaped array
430 for (var j=0; template.webgl[j]; j++) { 449 for (var j=0; template.webgl[j]; j++) {
431 if (j === 0) { 450 if (j === 0) {
@@ -438,6 +457,15 @@ function initWebGl (e) {\n\
438 json += '\n\t\t]\n})\n'; 457 json += '\n\t\t]\n})\n';
439 //Setting string in tag 458 //Setting string in tag
440 webgltag.innerHTML = json; 459 webgltag.innerHTML = json;
460 /*
461webgltag.innerHTML = json.replace(/assets\//gi, webGlDirSwap);
462 //
463 function webGlDirSwap (dir) {
464 return rdgeDirName+'/';
465 }
466 //
467 console.log(webgltag.innerHTML);
468*/
441 } 469 }
442 //Cleaning URLs from HTML 470 //Cleaning URLs from HTML
443 var cleanHTML = template.document.content.document.documentElement.outerHTML.replace(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi, parseNinjaRootUrl.bind(this)); 471 var cleanHTML = template.document.content.document.documentElement.outerHTML.replace(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi, parseNinjaRootUrl.bind(this));