]> git.scottworley.com Git - nt3d/commitdiff
Pass numeric parameters as numbers
authorScott Worley <ScottWorley@ScottWorley.com>
Wed, 19 Dec 2012 15:08:16 +0000 (07:08 -0800)
committerScott Worley <ScottWorley@ScottWorley.com>
Wed, 19 Dec 2012 15:08:16 +0000 (07:08 -0800)
box_by_extrude.html
box_by_faces.html
box_by_quadstrip.html
box_by_rotation.html
box_by_trianglefan.html
nt3d.js

index 6a883a60eb7e9fb6b04f1809f51d5a0c2e3df048..a95a7d300a7b90243c28954838cafb7a887491ad 100644 (file)
@@ -3,8 +3,7 @@
     <title>Box by extrude</title>
     <script type="text/javascript" src="nt3d.js"></script>
     <script type="text/javascript">
-      function box_by_extrude(size_as_string) {
-        var size = parseFloat(size_as_string);
+      function box_by_extrude(size) {
         var origin = [0,    0,    0];
         var x      = [size, 0,    0];
         var y      = [0,    size, 0];
index 1a88d8c2b434be57ee3ce26a91da03f6e1dcc12a..b27d79551896ffdc403a49752d74760b8a858e35 100644 (file)
@@ -3,8 +3,7 @@
     <title>Box by faces</title>
     <script type="text/javascript" src="nt3d.js"></script>
     <script type="text/javascript">
-      function box_by_faces(size_as_string) {
-        var size = parseFloat(size_as_string);
+      function box_by_faces(size) {
         var origin = [0,    0,    0   ];
         var x      = [size, 0,    0   ];
         var y      = [0,    size, 0   ];
index 1c6f8faeed36ea285771af9fdcac52bd5921a8a5..83ad5ab47fd21ccaa70aceb941ec3889f75d31f3 100644 (file)
@@ -3,8 +3,7 @@
     <title>Box by quadstrip</title>
     <script type="text/javascript" src="nt3d.js"></script>
     <script type="text/javascript">
-      function box_by_quadstrip(size_as_string) {
-        var size = parseFloat(size_as_string);
+      function box_by_quadstrip(size) {
         var origin = [0,    0,    0   ];
         var x      = [size, 0,    0   ];
         var y      = [0,    size, 0   ];
index 396c7147a76472b3e1e5e2d61938b130fde6fd85..d575a426717b9ddcb5731473b2d61834f7b28f9c 100644 (file)
@@ -3,8 +3,7 @@
     <title>Box by rotation</title>
     <script type="text/javascript" src="nt3d.js"></script>
     <script type="text/javascript">
-      function box_by_rotation(size_as_string) {
-        var size = parseFloat(size_as_string);
+      function box_by_rotation(size) {
         var origin = [0,    0,    0   ];
         var x      = [size, 0,    0   ];
         var y      = [0,    size, 0   ];
index 7d4271b5c6e6892fa191d8b30972337919f8885a..7c0519cdeaab460910a244dd7f4a996850f4b444 100644 (file)
@@ -3,8 +3,7 @@
     <title>Box by trianglefan</title>
     <script type="text/javascript" src="nt3d.js"></script>
     <script type="text/javascript">
-      function box_by_trianglefan(size_as_string) {
-        var size = parseFloat(size_as_string);
+      function box_by_trianglefan(size) {
         var origin = [0,    0,    0   ];
         var x      = [size, 0,    0   ];
         var y      = [0,    size, 0   ];
diff --git a/nt3d.js b/nt3d.js
index 1cabfb1bf2ffb6fd9394356a7dccb7346f394c74..4cec096683d971b7c95b0b390c3e88725bad6a0e 100644 (file)
--- a/nt3d.js
+++ b/nt3d.js
@@ -200,7 +200,9 @@ nt3d = {
                // Get params from form
                var params = [];
                for (var i = 0; i < this.user_params.length; i++) {
-                       params[i] = this.form.elements["param"+i].value;
+                       var as_string = this.form.elements["param"+i].value;
+                       var as_num = +as_string;
+                       params[i] = isNaN(as_num) ? as_string : as_num;
                }
 
                // Run user_function