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 | |
parent | 46defc9bd11bf077efd672c72787a3b67da1a178 (diff) | |
parent | 4d7b86f55c504ee4e8c2460cf6b60cb9a2cf18f0 (diff) | |
download | ninja-f6c7b88404cfa44f468170f1219b565fda3e38c1.tar.gz |
Merge pull request #5 from joseeight/FileIO-Integration
Clean-Up
-rw-r--r-- | assets/canvas-runtime.js (renamed from assets/CanvasRuntime.js) | 14 | ||||
-rw-r--r-- | assets/descriptor.json | 4 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 34 |
3 files changed, 25 insertions, 27 deletions
diff --git a/assets/CanvasRuntime.js b/assets/canvas-runtime.js index 445050bc..655e52fa 100644 --- a/assets/CanvasRuntime.js +++ b/assets/canvas-runtime.js | |||
@@ -4,6 +4,20 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | /////////////////////////////////////////////////////////////////////// | ||
8 | //Loading webGL/canvas data | ||
9 | function initWebGl (rootElement, directory) { | ||
10 | var cvsDataMngr, ninjaWebGlData = JSON.parse((document.querySelectorAll(['script[data-ninja-webgl]'])[0].innerHTML.replace('(', '')).replace(')', '')); | ||
11 | if (ninjaWebGlData && ninjaWebGlData.data) { | ||
12 | for (var n=0; ninjaWebGlData.data[n]; n++) { | ||
13 | ninjaWebGlData.data[n] = unescape(ninjaWebGlData.data[n]); | ||
14 | } | ||
15 | } | ||
16 | //Creating data manager | ||
17 | cvsDataMngr = new CanvasDataManager(); | ||
18 | //Loading data to canvas(es) | ||
19 | cvsDataMngr.loadGLData(rootElement, ninjaWebGlData.data, directory); | ||
20 | } | ||
7 | 21 | ||
8 | /////////////////////////////////////////////////////////////////////// | 22 | /////////////////////////////////////////////////////////////////////// |
9 | // Class ShapeRuntime | 23 | // Class ShapeRuntime |
diff --git a/assets/descriptor.json b/assets/descriptor.json index 0da58755..af0520dd 100644 --- a/assets/descriptor.json +++ b/assets/descriptor.json | |||
@@ -1,10 +1,10 @@ | |||
1 | { | 1 | { |
2 | "copyright": "This file contains proprietary software owned by Motorola Mobility, Inc. No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder. (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.", | 2 | "copyright": "This file contains proprietary software owned by Motorola Mobility, Inc. No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder. (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.", |
3 | "version": "0.5.1.0", | 3 | "version": "0.0.0.0", |
4 | "root": "/assets/", | 4 | "root": "/assets/", |
5 | "directories": [{"name": "images"}, {"name": "shaders"}], | 5 | "directories": [{"name": "images"}, {"name": "shaders"}], |
6 | "files": [ | 6 | "files": [ |
7 | "CanvasRuntime.js", | 7 | "canvas-runtime.js", |
8 | "rdge-compiled.js", | 8 | "rdge-compiled.js", |
9 | "images/BoxB2_AO.png", | 9 | "images/BoxB2_AO.png", |
10 | "images/grey.png", | 10 | "images/grey.png", |
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)); |