Browse Source

Updated example

tentone 5 years ago
parent
commit
0ed7e99bd2
1 changed files with 21 additions and 1 deletions
  1. 21 1
      examples/node.html

+ 21 - 1
examples/node.html

@@ -123,7 +123,7 @@
 			}
 			}
 		}
 		}
 
 
-		Escher.Object2D.register(OperationNode, "OperationNode");
+
 
 
 		class NumberInputNode extends Escher.Node
 		class NumberInputNode extends Escher.Node
 		{
 		{
@@ -131,6 +131,8 @@
 			{
 			{
 				super();
 				super();
 
 
+				this.type = "NumberInputNode";
+
 				this.box.set(new Escher.Vector2(-50, -30), new Escher.Vector2(50, 30));
 				this.box.set(new Escher.Vector2(-50, -30), new Escher.Vector2(50, 30));
 
 
 				this.div = new Escher.DOM("input");
 				this.div = new Escher.DOM("input");
@@ -155,6 +157,19 @@
 					return this.div.element.value;
 					return this.div.element.value;
 				};
 				};
 			}
 			}
+
+			serialize(recursive)
+			{
+				var data = super.serialize(recursive);
+				data.value = this.div.element.value;
+				return data;
+			}
+
+			parse(data, root)
+			{
+				super.parse(data, root);
+				this.div.element.value = data.value;
+			}
 		}
 		}
 
 
 		class ResultNode extends Escher.Node
 		class ResultNode extends Escher.Node
@@ -163,6 +178,8 @@
 			{
 			{
 				super();
 				super();
 
 
+				this.type = "ResultNode";
+
 				this.box.set(new Escher.Vector2(-100, -20), new Escher.Vector2(100, 20));
 				this.box.set(new Escher.Vector2(-100, -20), new Escher.Vector2(100, 20));
 
 
 				this.text = new Escher.Text();
 				this.text = new Escher.Text();
@@ -193,6 +210,9 @@
 			}
 			}
 		}
 		}
 
 
+		Escher.Object2D.register(OperationNode, "OperationNode");
+		Escher.Object2D.register(NumberInputNode, "NumberInputNode");
+		Escher.Object2D.register(ResultNode, "ResultNode");
 
 
 		var graph = new Escher.NodeGraph();
 		var graph = new Escher.NodeGraph();