]> git.scottworley.com Git - nt3d/blobdiff - nt3d.js
Reduce defaults for a smaller output file
[nt3d] / nt3d.js
diff --git a/nt3d.js b/nt3d.js
index bc11c71520157e9b708ace929d7c7ce71d5bcc6d..80390b99b6db1482a0550555246a8335bf3d133e 100644 (file)
--- a/nt3d.js
+++ b/nt3d.js
@@ -418,17 +418,17 @@ nt3d = {
 
                // Continue in a callback, so that there's not a stale download
                // link hanging around while we process.
-               setTimeout(function(the_this) { (function() {
+               setTimeout(function() {
 
                // Get params from form
-               var params = [];
+               var params = {};
                for (var i = 0; i < this.user_params.length; i++) {
                        var as_string = this.form.elements["param"+i].value;
                        var as_num = +as_string;
-                       params[i] = isNaN(as_num) ? as_string : as_num;
+                       params[this.user_params[i][0]] = isNaN(as_num) ? as_string : as_num;
                }
 
-               this.points = this.user_function.apply(null, params);
+               this.points = this.user_function.call(null, params);
 
                this.validate(this.points);
 
@@ -446,7 +446,7 @@ nt3d = {
                this.ui.appendChild(download_link);
                setTimeout(function() { download_link.setAttribute("style", "-webkit-transition: background-color 0.4s; -moz-transition: background-color 0.4s; -o-transition: background-color 0.4s; -ms-transition: background-color 0.4s; transition: background-color 0.4s; background-color: inherit"); }, 0);
 
-               }).call(the_this); }, 0, this); // (We were in a callback this whole time, remember?)
+               }.bind(this), 0); // (We were in a callback this whole time, remember?)
        },
        framework: function (f, params) {
                this.user_function = f;
@@ -476,7 +476,18 @@ nt3d = {
                        tr = document.createElement("tr");
                        table.appendChild(tr);
                        var td = document.createElement("td");
-                       td.appendChild(document.createTextNode(params[i][0]));
+                       var description;
+                       if (params[i].length > 2) {
+                               description = params[i][2];
+                       } else {
+                               description = params[i][0];
+                               description = description[0].toUpperCase() + description.substr(1);
+                               description = description.replace(/_(.)/g, function(_, c) {
+                                       return " " + c.toUpperCase();
+                               });
+                               description = description.replace("Num ", "Number of ");
+                       }
+                       td.appendChild(document.createTextNode(description));
                        tr.appendChild(td);
                        td = document.createElement("td");
                        var input = document.createElement("input");