diff options
author | Eric | 2012-03-13 10:54:53 -0700 |
---|---|---|
committer | Eric | 2012-03-13 10:54:53 -0700 |
commit | f6c7b88404cfa44f468170f1219b565fda3e38c1 (patch) | |
tree | df33988e4240ea868d91fe07f35cc3c72f6ac307 /js | |
parent | 46defc9bd11bf077efd672c72787a3b67da1a178 (diff) | |
parent | 4d7b86f55c504ee4e8c2460cf6b60cb9a2cf18f0 (diff) | |
download | ninja-f6c7b88404cfa44f468170f1219b565fda3e38c1.tar.gz |
Merge pull request #5 from joseeight/FileIO-Integration
Clean-Up
Diffstat (limited to 'js')
-rw-r--r-- | js/mediators/io-mediator.js | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index e9661f20..d81f4543 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -408,7 +408,7 @@ exports.IoMediator = Montage.create(Component, { | |||
408 | if (!webgllibtag) { | 408 | if (!webgllibtag) { |
409 | webgllibtag = template.document.content.document.createElement('script'); | 409 | webgllibtag = template.document.content.document.createElement('script'); |
410 | webgllibtag.setAttribute('type', 'text/javascript'); | 410 | webgllibtag.setAttribute('type', 'text/javascript'); |
411 | webgllibtag.setAttribute('src', rdgeDirName+'/CanvasRuntime.js'); | 411 | webgllibtag.setAttribute('src', rdgeDirName+'/canvas-runtime.js'); |
412 | webgllibtag.setAttribute('data-ninja-webgl-lib', 'true'); | 412 | webgllibtag.setAttribute('data-ninja-webgl-lib', 'true'); |
413 | template.document.content.document.head.appendChild(webgllibtag); | 413 | template.document.content.document.head.appendChild(webgllibtag); |
414 | } | 414 | } |
@@ -418,7 +418,7 @@ exports.IoMediator = Montage.create(Component, { | |||
418 | webgltag.setAttribute('data-ninja-webgl', 'true'); | 418 | webgltag.setAttribute('data-ninja-webgl', 'true'); |
419 | template.document.content.document.head.appendChild(webgltag); | 419 | template.document.content.document.head.appendChild(webgltag); |
420 | } | 420 | } |
421 | // | 421 | //TODO: Remove this tag and place inside JS file |
422 | if (!webgljstag) { | 422 | if (!webgljstag) { |
423 | webgljstag = template.document.content.document.createElement('script'); | 423 | webgljstag = template.document.content.document.createElement('script'); |
424 | webgljstag.setAttribute('type', 'text/javascript'); | 424 | webgljstag.setAttribute('type', 'text/javascript'); |
@@ -426,24 +426,17 @@ exports.IoMediator = Montage.create(Component, { | |||
426 | template.document.content.document.head.appendChild(webgljstag); | 426 | template.document.content.document.head.appendChild(webgljstag); |
427 | } | 427 | } |
428 | //TODO: Decide if this should be over-writter or only written on creation | 428 | //TODO: Decide if this should be over-writter or only written on creation |
429 | var rootElement = 'document.body'; //TODO: Set actual root element | ||
429 | webgljstag.innerHTML = "\ | 430 | webgljstag.innerHTML = "\ |
430 | //Loading webGL/canvas data on window load\n\ | 431 | //Loading webGL/canvas data on window load\n\ |
431 | window.addEventListener('load', initWebGl, false);\n\ | 432 | window.addEventListener('load', loadWebGL, false);\n\ |
432 | function initWebGl (e) {\n\ | 433 | function loadWebGL (e) {\n\ |
433 | window.removeEventListener('load', initWebGl, false);\n\ | 434 | window.removeEventListener('load', loadWebGL, false);\n\ |
434 | var cvsDataMngr, ninjaWebGlData = JSON.parse((document.querySelectorAll(['script[data-ninja-webgl]'])[0].innerHTML.replace(\"(\", \"\")).replace(\")\", \"\"));\n\ | 435 | //Calling method to initialize all webGL/canvas(es)\n\ |
435 | if (ninjaWebGlData && ninjaWebGlData.data) {\n\ | 436 | initWebGl("+rootElement+", '"+rdgeDirName+"/');\n\ |
436 | for (var n=0; ninjaWebGlData.data[n]; n++) {\n\ | ||
437 | ninjaWebGlData.data[n] = unescape(ninjaWebGlData.data[n]);\n\ | ||
438 | }\n\ | ||
439 | }\n\ | ||
440 | //Creating data manager\n\ | ||
441 | cvsDataMngr = new CanvasDataManager();\n\ | ||
442 | //Loading data to canvas(es)\n\ | ||
443 | cvsDataMngr.loadGLData(document.body, ninjaWebGlData.data, '"+rdgeDirName+"/');\n\ | ||
444 | }\ | 437 | }\ |
445 | "; | 438 | "; |
446 | //TODO: Add version and other data for RDGE | 439 | //TODO: This data should be saved to a JSON file eventually |
447 | json = '\n({\n\t"version": "'+rdgeVersion+'",\n\t"directory": "'+rdgeDirName+'/",\n\t"data": ['; | 440 | json = '\n({\n\t"version": "'+rdgeVersion+'",\n\t"directory": "'+rdgeDirName+'/",\n\t"data": ['; |
448 | //Looping through data to create escaped array | 441 | //Looping through data to create escaped array |
449 | for (var j=0; template.webgl[j]; j++) { | 442 | for (var j=0; template.webgl[j]; j++) { |
@@ -457,15 +450,6 @@ function initWebGl (e) {\n\ | |||
457 | json += '\n\t\t]\n})\n'; | 450 | json += '\n\t\t]\n})\n'; |
458 | //Setting string in tag | 451 | //Setting string in tag |
459 | webgltag.innerHTML = json; | 452 | webgltag.innerHTML = json; |
460 | /* | ||
461 | webgltag.innerHTML = json.replace(/assets\//gi, webGlDirSwap); | ||
462 | // | ||
463 | function webGlDirSwap (dir) { | ||
464 | return rdgeDirName+'/'; | ||
465 | } | ||
466 | // | ||
467 | console.log(webgltag.innerHTML); | ||
468 | */ | ||
469 | } | 453 | } |
470 | //Cleaning URLs from HTML | 454 | //Cleaning URLs from HTML |
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)); | 455 | 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)); |