From 07c48708a99b94a220c043ad5951a331bbd4fc2d Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 29 Feb 2012 15:23:28 -0800 Subject: WebGL file I/O --- js/document/html-document.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 76436732..7dd28385 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -185,7 +185,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { var elt = this.documentRoot; if (elt) { - console.log( "load canvas data: " , value ); + //console.log( "load canvas data: " , value ); var cdm = new CanvasDataManager(); cdm.loadGLData(elt, value); } -- cgit v1.2.3 From 232784ffafe834f75a46ca7fc311e8ca2ff5eec9 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 5 Mar 2012 16:33:51 -0800 Subject: Corrections for canvas file IO --- js/document/html-document.js | 69 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 7dd28385..f1b99866 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -185,9 +185,51 @@ exports.HTMLDocument = Montage.create(TextDocument, { var elt = this.documentRoot; if (elt) { - //console.log( "load canvas data: " , value ); - var cdm = new CanvasDataManager(); - cdm.loadGLData(elt, value); + var loadForRuntime = true; + if (loadForRuntime) + { + //console.log( "load canvas data: " , value ); + var cdm = new CanvasDataManager(); + cdm.loadGLData(elt, value, NJUtils); + } + else + { + var nWorlds= value.length; + for (var i=0; i= 0) + { + var endIndex = importStr.indexOf( "\n", startIndex ); + if (endIndex > 0) + { + var id = importStr.substring( startIndex+4, endIndex ); + if (id) + { + var canvas = this.findCanvasWithID( id, elt ); + if (canvas) + { + if (!canvas.elementModel) + { + NJUtils.makeElementModel(canvas, "Canvas", "shape", true); + } + + if (canvas.elementModel) + { + if (canvas.elementModel.shapeModel.GLWorld) + canvas.elementModel.shapeModel.GLWorld.clearTree(); + + var world = new GLWorld( canvas ); + canvas.elementModel.shapeModel.GLWorld = world; + world.import( importStr ); + } + } + } + } + } + } + } } } }, @@ -219,6 +261,27 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } }, + + /** + * search the DOM tree to find a canvas with the given id + */ + findCanvasWithID: { + value: function( id, elt ) { + var cid = elt.getAttribute( "data-RDGE-id" ); + if (cid == id) return elt; + + if (elt.children) + { + var nKids = elt.children.length; + for (var i=0; i= 0) + var world = new GLWorld( canvas, useWebGL ); world.import( importStr ); + canvas.elementModel.shapeModel.GLWorld = world; + + /////////////////////////// + //something.buildShapeModel( world ); // to come from Nivesh } } } -- cgit v1.2.3 From 11c3fa444217a34fa481b156d4d919d10e817350 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 6 Mar 2012 13:10:19 -0800 Subject: update the shapeModel after import --- js/document/html-document.js | 48 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 8722e223..f1847357 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -226,8 +226,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { world.import( importStr ); canvas.elementModel.shapeModel.GLWorld = world; - /////////////////////////// - //something.buildShapeModel( world ); // to come from Nivesh + this.buildShapeModel( canvas.elementModel.shapeModel, world ); } } } @@ -239,6 +238,51 @@ exports.HTMLDocument = Montage.create(TextDocument, { } }, + buildShapeModel: + { + value: function( shapeModel, world ) + { + shapeModel.shapeCount = 1; // for now... + shapeModel.useWebGl = world._useWebGL; + shapeModel.GLWorld = world; + var root = world.getGeomRoot(); + if (root) + { + shapeModel.GLGeomObj = root; + shapeModel.strokeSize = root._strokeWidth; + shapeModel.stroke = root._strokeColor.slice(); + shapeModel.strokeMaterial = root._strokeMaterial.dup(); + shapeModel.strokeStyle = "solid"; + //shapeModel.strokeStyleIndex + //shapeModel.border + shapeModel.fill = root._fillColor.slice(); + shapeModel.fillMaterial = root._fillMaterial.dup(); + //shapeModel.background + switch (root.geomType()) + { + case root.GEOM_TYPE_RECTANGLE: + shapeModel.tlRadius = root._tlRadius; + shapeModel.trRadius = root._trRadius; + shapeModel.blRadius = root._blRadius; + shapeModel.brRadius = root._brRadius; + break; + + case root.GEOM_TYPE_CIRCLE: + shapeModel.innerRadius = root._innerRadius; + break; + + case root.GEOM_TYPE_LINE: + shapeModel.slope = root._slope; + break; + + default: + console.log( "geometry type not supported for file I/O, " + root.geomType()); + break; + } + } + } + }, + zoomFactor: { get: function() { return this._zoomFactor; }, set: function(value) { this._zoomFactor = value; } -- cgit v1.2.3 From 3fcb463816a399b5474114725322653a20a22e9a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 6 Mar 2012 13:42:27 -0800 Subject: Updated buildShapeModel to set PI and selection values too and also avoid fill material for lines. Signed-off-by: Nivesh Rajbhandari --- js/document/html-document.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index f1847357..00cf0164 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -226,7 +226,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { world.import( importStr ); canvas.elementModel.shapeModel.GLWorld = world; - this.buildShapeModel( canvas.elementModel.shapeModel, world ); + this.buildShapeModel( canvas.elementModel, world ); } } } @@ -240,8 +240,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { buildShapeModel: { - value: function( shapeModel, world ) + value: function( elementModel, world ) { + var shapeModel = elementModel.shapeModel; shapeModel.shapeCount = 1; // for now... shapeModel.useWebGl = world._useWebGL; shapeModel.GLWorld = world; @@ -255,12 +256,14 @@ exports.HTMLDocument = Montage.create(TextDocument, { shapeModel.strokeStyle = "solid"; //shapeModel.strokeStyleIndex //shapeModel.border - shapeModel.fill = root._fillColor.slice(); - shapeModel.fillMaterial = root._fillMaterial.dup(); //shapeModel.background switch (root.geomType()) { case root.GEOM_TYPE_RECTANGLE: + elementModel.selection = "Rectangle"; + elementModel.pi = "RectanglePi"; + shapeModel.fill = root._fillColor.slice(); + shapeModel.fillMaterial = root._fillMaterial.dup(); shapeModel.tlRadius = root._tlRadius; shapeModel.trRadius = root._trRadius; shapeModel.blRadius = root._blRadius; @@ -268,10 +271,16 @@ exports.HTMLDocument = Montage.create(TextDocument, { break; case root.GEOM_TYPE_CIRCLE: + elementModel.selection = "Oval"; + elementModel.pi = "OvalPi"; + shapeModel.fill = root._fillColor.slice(); + shapeModel.fillMaterial = root._fillMaterial.dup(); shapeModel.innerRadius = root._innerRadius; break; case root.GEOM_TYPE_LINE: + elementModel.selection = "Line"; + elementModel.pi = "LinePi"; shapeModel.slope = root._slope; break; -- cgit v1.2.3 From 9e4ee2470726e3334eb47d904a6f4079d4ed7aef Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 17:01:39 -0800 Subject: IKNINJA-1270: fixed browser crashing when you close a document while playing a video then wait for a while Signed-off-by: Ananya Sen --- js/document/html-document.js | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 80930af2..d90231e3 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -824,6 +824,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start + + //pause videos on switching or closing the document, so that the browser does not keep downloading the media data + this.pauseVideos(); } }, @@ -852,6 +855,42 @@ exports.HTMLDocument = Montage.create(TextDocument, { } - } + }, //////////////////////////////////////////////////////////////////// + /** + *pause videos on switching or closing the document, so that the browser does not keep downloading the media data + *removeSrc : boolean to remove the src if the video... set only in the close document flow + */ + pauseVideos:{ + value:function(removeSrc){ + console.log("$$$ pauseVideos"); + var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; + for(i=0;i --- js/document/html-document.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index d90231e3..924a013d 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -863,16 +863,16 @@ exports.HTMLDocument = Montage.create(TextDocument, { */ pauseVideos:{ value:function(removeSrc){ - console.log("$$$ pauseVideos"); + //console.log("$$$ pauseVideos"); var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; for(i=0;i --- js/document/html-document.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 9670e0c4..83f91c19 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -894,7 +894,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { /** * remove the video src on closing the document, so that the browser does not keep downloading the media data, if the tag does not get garbage collected - *removeSrc : boolean to remove the src if the video... set only in the close document flow */ stopVideos:{ value:function(){ -- cgit v1.2.3 From 250420d8c6154172b27fe53aff30e78c227e8a67 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 7 Mar 2012 14:26:37 -0800 Subject: minor fixes Signed-off-by: Ananya Sen --- js/document/html-document.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 83f91c19..f730b853 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -872,22 +872,15 @@ exports.HTMLDocument = Montage.create(TextDocument, { }, //////////////////////////////////////////////////////////////////// /** - *pause videos on switching or closing the document, so that the browser does not keep downloading the media data - *removeSrc : boolean to remove the src if the video... set only in the close document flow + *pause videos on switching or closing the document */ pauseVideos:{ - value:function(removeSrc){ - //console.log("$$$ pauseVideos"); + value:function(){ var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; for(i=0;i= 0) var world = new GLWorld( canvas, useWebGL ); world.import( importStr ); - canvas.elementModel.shapeModel.GLWorld = world; this.buildShapeModel( canvas.elementModel, world ); } @@ -789,8 +790,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } } - //return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; - return {mode: 'html', document: this._userDocument, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; } else if (this.currentView === "code"){ //TODO: Would this get call when we are in code of HTML? } else { @@ -813,8 +813,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } } - //return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; - return {mode: 'html', document: this._userDocument, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; } else if (this.currentView === "code"){ //TODO: Would this get call when we are in code of HTML? } else { -- cgit v1.2.3 From 9e812f35ffa751e9215c5427c0c44005bd357924 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 7 Mar 2012 17:18:38 -0800 Subject: Fixed a few problems with Plasma material. --- js/document/html-document.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 44f90d41..0a3497f1 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -190,7 +190,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { var loadForRuntime = true; if (loadForRuntime) { - //console.log( "load canvas data: " , value ); var cdm = new CanvasDataManager(); cdm.loadGLData(elt, value, NJUtils); } -- cgit v1.2.3 From 710a17a23dee948304bad79d40424c3a477b6cc4 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 8 Mar 2012 09:50:40 -0800 Subject: Commented out code for loading for runtime --- js/document/html-document.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 0a3497f1..b75eb226 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -187,13 +187,15 @@ exports.HTMLDocument = Montage.create(TextDocument, { var elt = this.documentRoot; if (elt) { - var loadForRuntime = true; - if (loadForRuntime) - { - var cdm = new CanvasDataManager(); - cdm.loadGLData(elt, value, NJUtils); - } - else +// FOR JOSE: The following commented out lines are what the runtime +// version should execute. +// var loadForRuntime = true; +// if (loadForRuntime) +// { +// var cdm = new CanvasDataManager(); +// cdm.loadGLData(elt, value, NJUtils); +// } +// else { var nWorlds= value.length; for (var i=0; i= 0) - { - var endIndex = importStr.indexOf( "\n", startIndex ); - if (endIndex > 0) - { - var id = importStr.substring( startIndex+4, endIndex ); - if (id) - { - var canvas = this.findCanvasWithID( id, elt ); - if (canvas) - { - if (!canvas.elementModel) - { - NJUtils.makeElementModel(canvas, "Canvas", "shape", true); - } - - if (canvas.elementModel) - { - if (canvas.elementModel.shapeModel.GLWorld) - canvas.elementModel.shapeModel.GLWorld.clearTree(); - - var index = importStr.indexOf( "webGL: " ); - var useWebGL = (index >= 0) - var world = new GLWorld( canvas, useWebGL ); - world.import( importStr ); - - this.buildShapeModel( canvas.elementModel, world ); + var nWorlds= value.length; + for (var i=0; i= 0) { + var endIndex = importStr.indexOf("\n", startIndex); + if (endIndex > 0) { + var id = importStr.substring( startIndex+4, endIndex); + if (id) { + var canvas = this.findCanvasWithID(id, elt); + if (canvas) { + if (!canvas.elementModel) { + NJUtils.makeElementModel(canvas, "Canvas", "shape", true); + } + if (canvas.elementModel) { + if (canvas.elementModel.shapeModel.GLWorld) { + canvas.elementModel.shapeModel.GLWorld.clearTree(); } + var index = importStr.indexOf( "webGL: " ); + var useWebGL = (index >= 0) + var world = new GLWorld(canvas, useWebGL); + world.import( importStr ); + this.buildShapeModel(canvas.elementModel, world); } } } -- cgit v1.2.3 From 7b6e8194b91168abdeb94702eb350d14f147858b Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 8 Mar 2012 17:29:18 -0800 Subject: Canvas IO --- js/document/html-document.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 078a73b5..b2113623 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -9,7 +9,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, TextDocument = require("js/document/text-document").TextDocument, NJUtils = require("js/lib/NJUtils").NJUtils, - CanvasDataManager = require("js/lib/rdge/runtime/CanvasDataManager").CanvasDataManager, GLWorld = require("js/lib/drawing/world").World; //////////////////////////////////////////////////////////////////////// // @@ -174,9 +173,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { this._glData = null; if (elt) { - var cdm = new CanvasDataManager(); this._glData = []; - cdm.collectGLData( elt, this._glData ); + var path = "assets/"; + this.collectGLData( elt, this._glData, path ); } return this._glData; @@ -187,9 +186,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { var elt = this.documentRoot; if (elt) { -// FOR JOSE: The following commented out lines are what the runtime -// version should execute. -// var loadForRuntime = true; +// var loadForRuntime = false; // if (loadForRuntime) // { // var cdm = new CanvasDataManager(); @@ -367,11 +364,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { collectGLData: { - value: function( elt, dataArray ) + value: function( elt, dataArray, imagePath ) { if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) { - var data = elt.elementModel.shapeModel.GLWorld.export(); + var data = elt.elementModel.shapeModel.GLWorld.export( imagePath ); dataArray.push( data ); } @@ -381,7 +378,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { for (var i=0; i= 0) - { - var endIndex = importStr.indexOf( "\n", startIndex ); - if (endIndex > 0) - { - var id = importStr.substring( startIndex+4, endIndex ); - if (id) - { - var canvas = this.findCanvasWithID( id, elt ); - if (canvas) - { - if (!canvas.elementModel) - { - NJUtils.makeElementModel(canvas, "Canvas", "shape", true); - } - - if (canvas.elementModel) - { - if (canvas.elementModel.shapeModel.GLWorld) - canvas.elementModel.shapeModel.GLWorld.clearTree(); - - var index = importStr.indexOf( "webGL: " ); - var useWebGL = (index >= 0) - var world = new GLWorld( canvas, useWebGL ); - world.import( importStr ); - - this.buildShapeModel( canvas.elementModel, world ); + if (elt) { + var nWorlds= value.length; + for (var i=0; i= 0) { + var endIndex = importStr.indexOf( "\n", startIndex ); + if (endIndex > 0) { + var id = importStr.substring( startIndex+4, endIndex ); + if (id) { + var canvas = this.findCanvasWithID( id, elt ); + if (canvas) { + if (!canvas.elementModel) { + NJUtils.makeElementModel(canvas, "Canvas", "shape", true); + } + if (canvas.elementModel) { + if (canvas.elementModel.shapeModel.GLWorld) { + canvas.elementModel.shapeModel.GLWorld.clearTree(); } + var index = importStr.indexOf( "webGL: " ); + var useWebGL = (index >= 0) + var world = new GLWorld( canvas, useWebGL ); + world.import( importStr ); + this.buildShapeModel( canvas.elementModel, world ); } } } -- cgit v1.2.3 From e92a6da7b84c58803489d70efedf74837ddfe4cd Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 9 Mar 2012 13:34:09 -0800 Subject: Removed asset path replacement at authortime. --- js/document/html-document.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index aa56fd0e..f57c61ee 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -197,7 +197,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { //if (path) { //this.collectGLData(elt, this._glData, path); //} else { - this.collectGLData(elt, this._glData, "assets/"); + this.collectGLData(elt, this._glData ); //} } else { this._glData = null @@ -368,11 +368,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { collectGLData: { - value: function( elt, dataArray, imagePath ) + value: function( elt, dataArray ) { if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) { - var data = elt.elementModel.shapeModel.GLWorld.export( imagePath ); + var data = elt.elementModel.shapeModel.GLWorld.export(); dataArray.push( data ); } -- cgit v1.2.3 From a5d4d57a3575bb3b97fe692ddffca3127463ae94 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 9 Mar 2012 14:27:23 -0800 Subject: further removal of authortime asset path replacement. --- js/document/html-document.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index f57c61ee..79450494 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -382,7 +382,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { for (var i=0; i 0) { + setTimeout(function () {window.open(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]);}.bind(this), 3500); + } else { + window.open(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); + } //chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]}); } }, -- cgit v1.2.3