User editable parameters; debugging support; gears demo
This commit is contained in:
parent
1b89514039
commit
3544b92a1a
6 changed files with 749 additions and 108 deletions
448
openjscad.js
448
openjscad.js
|
@ -197,16 +197,6 @@ OpenJsCad.Viewer.csgToMesh = function(csg) {
|
|||
return mesh;
|
||||
};
|
||||
|
||||
// parse javascript into solid:
|
||||
OpenJsCad.javaScriptToSolid = function(script) {
|
||||
var csg = new Function(script)();
|
||||
if( (typeof(csg) != "object") || (!('polygons' in csg)))
|
||||
{
|
||||
throw new Error("Your javascript code should return a CSG object. Try for example: return CSG.cube();");
|
||||
}
|
||||
return csg;
|
||||
};
|
||||
|
||||
// this is a bit of a hack; doesn't properly supports urls that start with '/'
|
||||
// but does handle relative urls containing ../
|
||||
OpenJsCad.makeAbsoluteUrl = function(url, baseurl) {
|
||||
|
@ -246,10 +236,48 @@ OpenJsCad.makeAbsoluteUrl = function(url, baseurl) {
|
|||
OpenJsCad.isChrome = function()
|
||||
{
|
||||
return (navigator.userAgent.search("Chrome") >= 0);
|
||||
}
|
||||
};
|
||||
|
||||
// This is called from within the web worker. Execute the main() function of the supplied script
|
||||
// and post a message to the calling thread when finished
|
||||
OpenJsCad.runMainInWorker = function(mainParameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(typeof(main) != 'function') throw new Error('Your jscad file should contain a function main() which returns a CSG solid.');
|
||||
var csg = main(mainParameters);
|
||||
if( (typeof(csg) != "object") || (!(csg instanceof CSG)) )
|
||||
{
|
||||
throw new Error("Your main() function should return a CSG solid.");
|
||||
}
|
||||
self.postMessage({cmd: 'rendered', csg: csg});
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
var errtxt = e.stack;
|
||||
self.postMessage({cmd: 'error', err: errtxt});
|
||||
}
|
||||
};
|
||||
|
||||
OpenJsCad.javaScriptToSolidSync = function(script, mainParameters, callback) {
|
||||
var workerscript = "";
|
||||
workerscript += script;
|
||||
workerscript += "\n\n\n\n\n\n\n/* -------------------------------------------------------------------------\n";
|
||||
workerscript += "OpenJsCad debugging\n\nAssuming you are running Chrome:\nF10 steps over an instruction\nF11 steps into an instruction\n";
|
||||
workerscript += "F8 continues running\nPress the (||) button at the bottom to enable pausing whenever an error occurs\n";
|
||||
workerscript += "Click on a line number to set or clear a breakpoint\n";
|
||||
workerscript += "For more information see: http://code.google.com/chrome/devtools/docs/overview.html\n\n";
|
||||
workerscript += "------------------------------------------------------------------------- */\n";
|
||||
workerscript += "\n\n// Now press F11 twice to enter your main() function:\n\n";
|
||||
workerscript += "debugger;\n";
|
||||
workerscript += "return main("+JSON.stringify(mainParameters)+");";
|
||||
var f = new Function(workerscript);
|
||||
var csg = f();
|
||||
return csg;
|
||||
};
|
||||
|
||||
// callback: should be function(error, csg)
|
||||
OpenJsCad.javaScriptToSolidASync = function(script, callback) {
|
||||
OpenJsCad.javaScriptToSolidASync = function(script, mainParameters, callback) {
|
||||
var baselibraries = [
|
||||
"csg.js",
|
||||
"openjscad.js"
|
||||
|
@ -257,28 +285,37 @@ OpenJsCad.javaScriptToSolidASync = function(script, callback) {
|
|||
var baseurl = document.location + "";
|
||||
var workerscript = "";
|
||||
workerscript += script;
|
||||
workerscript += "\n//// END OF USER SUPPLIED SCRIPT\n";
|
||||
workerscript += "\n\n\n\n//// The following code is added by OpenJsCad:\n";
|
||||
workerscript += "var _csg_libraries=" + JSON.stringify(baselibraries)+";\n";
|
||||
workerscript += "var _csg_baseurl=" + JSON.stringify(baseurl)+";\n";
|
||||
workerscript += "var _csg_makeAbsoluteURL=" + OpenJsCad.makeAbsoluteUrl.toString()+";\n";
|
||||
workerscript += "if(typeof(libs) == 'function') _csg_libraries = _csg_libraries.concat(libs());\n";
|
||||
// workerscript += "if(typeof(libs) == 'function') _csg_libraries = _csg_libraries.concat(libs());\n";
|
||||
workerscript += "_csg_libraries = _csg_libraries.map(function(l){return _csg_makeAbsoluteURL(l,_csg_baseurl);});\n";
|
||||
//workerscript += "importScripts.call(null, _csg_libraries);\n";
|
||||
workerscript += "_csg_libraries.map(function(l){importScripts(l)});\n";
|
||||
workerscript += "self.addEventListener('message', function(e) {if(e.data && e.data.cmd == 'render'){";
|
||||
workerscript += " if(typeof(main) != 'function') throw new Error('Your jscad file should contain a function main() which returns a CSG solid.');\n";
|
||||
workerscript += " var csg = main(); self.postMessage({cmd: 'rendered', csg: csg});";
|
||||
workerscript += " OpenJsCad.runMainInWorker("+JSON.stringify(mainParameters)+");";
|
||||
// workerscript += " if(typeof(main) != 'function') throw new Error('Your jscad file should contain a function main() which returns a CSG solid.');\n";
|
||||
// workerscript += " var csg; try {csg = main("+JSON.stringify(mainParameters)+"); self.postMessage({cmd: 'rendered', csg: csg});}";
|
||||
// workerscript += " catch(e) {var errtxt = e.stack; self.postMessage({cmd: 'error', err: errtxt});}";
|
||||
workerscript += "}},false);\n";
|
||||
|
||||
|
||||
var blobURL = OpenJsCad.textToBlobUrl(workerscript);
|
||||
|
||||
if(!window.Worker) throw new Error("Your browser doesn't support Web Workers");
|
||||
if(!window.Worker) throw new Error("Your browser doesn't support Web Workers. Please try the Chrome browser instead.");
|
||||
var worker = new Worker(blobURL);
|
||||
worker.onmessage = function(e) {
|
||||
if(e.data && e.data.cmd == 'rendered')
|
||||
{
|
||||
var csg = CSG.fromObject(e.data.csg);
|
||||
callback(null, csg);
|
||||
if(e.data)
|
||||
{
|
||||
if(e.data.cmd == 'rendered')
|
||||
{
|
||||
var csg = CSG.fromObject(e.data.csg);
|
||||
callback(null, csg);
|
||||
}
|
||||
else if(e.data.cmd == "error")
|
||||
{
|
||||
// var errtxt = "Error in line "+e.data.err.lineno+": "+e.data.err.message;
|
||||
callback(e.data.err, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
worker.onerror = function(e) {
|
||||
|
@ -313,36 +350,20 @@ OpenJsCad.revokeBlobUrl = function(url) {
|
|||
else throw new Error("Your browser doesn't support window.URL");
|
||||
};
|
||||
|
||||
OpenJsCad.Processor = function(containerdiv, onchange) {
|
||||
this.containerdiv = containerdiv;
|
||||
this.onchange = onchange;
|
||||
this.viewerdiv = null;
|
||||
this.viewer = null;
|
||||
this.viewerwidth = 800;
|
||||
this.viewerheight = 600;
|
||||
this.initialViewerDistance = 50;
|
||||
this.processing = false;
|
||||
this.solid = null;
|
||||
this.validcsg = false;
|
||||
this.hasstl = false;
|
||||
this.worker = null;
|
||||
this.createElements();
|
||||
};
|
||||
|
||||
OpenJsCad.FileSystemApiErrorHandler = function(fileError, operation) {
|
||||
var errormap = {
|
||||
1: NOT_FOUND_ERR,
|
||||
2: SECURITY_ERR,
|
||||
3: ABORT_ERR,
|
||||
4: NOT_READABLE_ERR,
|
||||
5: ENCODING_ERR,
|
||||
6: NO_MODIFICATION_ALLOWED_ERR,
|
||||
7: INVALID_STATE_ERR,
|
||||
8: SYNTAX_ERR,
|
||||
9: INVALID_MODIFICATION_ERR,
|
||||
10: QUOTA_EXCEEDED_ERR,
|
||||
11: TYPE_MISMATCH_ERR,
|
||||
12: PATH_EXISTS_ERR,
|
||||
1: 'NOT_FOUND_ERR',
|
||||
2: 'SECURITY_ERR',
|
||||
3: 'ABORT_ERR',
|
||||
4: 'NOT_READABLE_ERR',
|
||||
5: 'ENCODING_ERR',
|
||||
6: 'NO_MODIFICATION_ALLOWED_ERR',
|
||||
7: 'INVALID_STATE_ERR',
|
||||
8: 'SYNTAX_ERR',
|
||||
9: 'INVALID_MODIFICATION_ERR',
|
||||
10: 'QUOTA_EXCEEDED_ERR',
|
||||
11: 'TYPE_MISMATCH_ERR',
|
||||
12: 'PATH_EXISTS_ERR',
|
||||
};
|
||||
var errname;
|
||||
if(fileError.code in errormap)
|
||||
|
@ -364,6 +385,55 @@ OpenJsCad.AlertUserOfUncaughtExceptions = function() {
|
|||
};
|
||||
};
|
||||
|
||||
// parse the jscad script to get the parameter definitions
|
||||
OpenJsCad.getParamDefinitions = function(script) {
|
||||
var scriptisvalid = true;
|
||||
try
|
||||
{
|
||||
// first try to execute the script itself
|
||||
// this will catch any syntax errors
|
||||
var f = new Function(script);
|
||||
f();
|
||||
}
|
||||
catch(e) {
|
||||
scriptisvalid = false;
|
||||
}
|
||||
var params = [];
|
||||
if(scriptisvalid)
|
||||
{
|
||||
var script1 = "if(typeof(getParameterDefinitions) == 'function') {return getParameterDefinitions();} else {return [];} ";
|
||||
script1 += script;
|
||||
var f = new Function(script1);
|
||||
params = f();
|
||||
if( (typeof(params) != "object") || (typeof(params.length) != "number") )
|
||||
{
|
||||
throw new Error("The getParameterDefinitions() function should return an array with the parameter definitions");
|
||||
}
|
||||
}
|
||||
return params;
|
||||
};
|
||||
|
||||
OpenJsCad.Processor = function(containerdiv, onchange) {
|
||||
this.containerdiv = containerdiv;
|
||||
this.onchange = onchange;
|
||||
this.viewerdiv = null;
|
||||
this.viewer = null;
|
||||
this.viewerwidth = 800;
|
||||
this.viewerheight = 600;
|
||||
this.initialViewerDistance = 50;
|
||||
this.processing = false;
|
||||
this.solid = null;
|
||||
this.validcsg = false;
|
||||
this.hasstl = false;
|
||||
this.worker = null;
|
||||
this.paramDefinitions = [];
|
||||
this.paramControls = [];
|
||||
this.script = null;
|
||||
this.hasError = false;
|
||||
this.debugging = false;
|
||||
this.createElements();
|
||||
};
|
||||
|
||||
OpenJsCad.Processor.prototype = {
|
||||
createElements: function() {
|
||||
while(this.containerdiv.children.length > 0)
|
||||
|
@ -390,9 +460,11 @@ OpenJsCad.Processor.prototype = {
|
|||
this.viewerdiv.innerHTML = e.toString();
|
||||
}
|
||||
this.errordiv = document.createElement("div");
|
||||
this.errordiv.style.display = "none";
|
||||
this.errorpre = document.createElement("pre");
|
||||
this.errordiv.appendChild(this.errorpre);
|
||||
this.statusdiv = document.createElement("div");
|
||||
this.statusdiv.style.width = this.viewerwidth + "px";
|
||||
this.statusdiv.className = "statusdiv";
|
||||
//this.statusdiv.style.width = this.viewerwidth + "px";
|
||||
this.statusspan = document.createElement("span");
|
||||
this.statusbuttons = document.createElement("div");
|
||||
this.statusbuttons.style.float = "right";
|
||||
|
@ -403,20 +475,36 @@ OpenJsCad.Processor.prototype = {
|
|||
var that = this;
|
||||
this.abortbutton.onclick = function(e) {
|
||||
that.abort();
|
||||
}
|
||||
};
|
||||
this.statusbuttons.appendChild(this.abortbutton);
|
||||
this.generateStlButton = document.createElement("button");
|
||||
this.generateStlButton.innerHTML = "Generate STL";
|
||||
this.generateStlButton.onclick = function(e) {
|
||||
that.generateStl();
|
||||
}
|
||||
};
|
||||
this.statusbuttons.appendChild(this.generateStlButton);
|
||||
this.downloadStlLink = document.createElement("a");
|
||||
this.downloadStlLink.innerHTML = "Download STL";
|
||||
this.statusbuttons.appendChild(this.downloadStlLink);
|
||||
this.parametersdiv = document.createElement("div");
|
||||
this.parametersdiv.className = "parametersdiv";
|
||||
var headerdiv = document.createElement("div");
|
||||
headerdiv.innerText = "Parameters:";
|
||||
headerdiv.className = "header";
|
||||
this.parametersdiv.appendChild(headerdiv);
|
||||
this.parameterstable = document.createElement("table");
|
||||
this.parameterstable.className = "parameterstable";
|
||||
this.parametersdiv.appendChild(this.parameterstable);
|
||||
var parseParametersButton = document.createElement("button");
|
||||
parseParametersButton.innerHTML = "Update";
|
||||
parseParametersButton.onclick = function(e) {
|
||||
that.rebuildSolid();
|
||||
};
|
||||
this.parametersdiv.appendChild(parseParametersButton);
|
||||
this.enableItems();
|
||||
this.containerdiv.appendChild(this.statusdiv);
|
||||
this.containerdiv.appendChild(this.errordiv);
|
||||
this.containerdiv.appendChild(this.parametersdiv);
|
||||
this.clearViewer();
|
||||
},
|
||||
|
||||
|
@ -447,11 +535,19 @@ OpenJsCad.Processor.prototype = {
|
|||
this.abortbutton.style.display = this.processing? "inline":"none";
|
||||
this.generateStlButton.style.display = ((!this.hasstl)&&(this.validcsg))? "inline":"none";
|
||||
this.downloadStlLink.style.display = this.hasstl? "inline":"none";
|
||||
this.parametersdiv.style.display = (this.paramControls.length > 0)? "block":"none";
|
||||
this.errordiv.style.display = this.hasError? "block":"none";
|
||||
this.statusdiv.style.display = this.hasError? "none":"block";
|
||||
},
|
||||
|
||||
setError: function(txt) {
|
||||
this.errordiv.innerHTML = txt;
|
||||
this.errordiv.style.display = (txt == "")? "none":"block";
|
||||
this.hasError = (txt != "");
|
||||
this.errorpre.innerText = txt;
|
||||
this.enableItems();
|
||||
},
|
||||
|
||||
setDebugging: function(debugging) {
|
||||
this.debugging = debugging;
|
||||
},
|
||||
|
||||
// script: javascript code
|
||||
|
@ -461,31 +557,128 @@ OpenJsCad.Processor.prototype = {
|
|||
filename = filename.replace(/\.jscad$/i, "");
|
||||
this.abort();
|
||||
this.clearViewer();
|
||||
this.paramDefinitions = [];
|
||||
this.paramControls = [];
|
||||
this.script = null;
|
||||
this.setError("");
|
||||
var scripthaserrors = false;
|
||||
try
|
||||
{
|
||||
this.paramDefinitions = OpenJsCad.getParamDefinitions(script);
|
||||
this.createParamControls();
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
this.setError(e.toString());
|
||||
this.statusspan.innerHTML = "Error.";
|
||||
scripthaserrors = true;
|
||||
}
|
||||
if(!scripthaserrors)
|
||||
{
|
||||
this.script = script;
|
||||
this.filename = filename;
|
||||
this.rebuildSolid();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.enableItems();
|
||||
if(this.onchange) this.onchange();
|
||||
}
|
||||
},
|
||||
|
||||
getParamValues: function()
|
||||
{
|
||||
var paramValues = {};
|
||||
for(var i = 0; i < this.paramDefinitions.length; i++)
|
||||
{
|
||||
var paramdef = this.paramDefinitions[i];
|
||||
var type = "text";
|
||||
if('type' in paramdef)
|
||||
{
|
||||
type = paramdef.type;
|
||||
}
|
||||
var control = this.paramControls[i];
|
||||
var value;
|
||||
if( (type == "text") || (type == "float") || (type == "int") )
|
||||
{
|
||||
value = control.value;
|
||||
if( (type == "float") || (type == "int") )
|
||||
{
|
||||
var isnumber = !isNaN(parseFloat(value)) && isFinite(value);
|
||||
if(!isnumber)
|
||||
{
|
||||
throw new Error("Not a number: "+value);
|
||||
}
|
||||
if(type == "int")
|
||||
{
|
||||
value = parseInt(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = parseFloat(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == "choice")
|
||||
{
|
||||
value = control.options[control.selectedIndex].value;
|
||||
}
|
||||
paramValues[paramdef.name] = value;
|
||||
}
|
||||
return paramValues;
|
||||
},
|
||||
|
||||
rebuildSolid: function()
|
||||
{
|
||||
this.abort();
|
||||
this.setError("");
|
||||
this.clearViewer();
|
||||
this.processing = true;
|
||||
this.statusspan.innerHTML = "Processing, please wait...";
|
||||
this.filename = filename;
|
||||
this.enableItems();
|
||||
var that = this;
|
||||
this.worker = OpenJsCad.javaScriptToSolidASync(script, function(err, csg) {
|
||||
that.processing = false;
|
||||
that.worker = null;
|
||||
if(err)
|
||||
{
|
||||
that.setError(err);
|
||||
that.statusspan.innerHTML = "Error.";
|
||||
}
|
||||
else
|
||||
var paramValues = this.getParamValues();
|
||||
if(this.debugging)
|
||||
{
|
||||
try
|
||||
{
|
||||
var csg = OpenJsCad.javaScriptToSolidSync(this.script, paramValues);
|
||||
that.processing = false;
|
||||
that.solid = csg;
|
||||
if(that.viewer) that.viewer.setCsg(csg);
|
||||
that.validcsg = true;
|
||||
that.statusspan.innerHTML = "Ready.";
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
that.processing = false;
|
||||
that.setError(e.toString());
|
||||
that.statusspan.innerHTML = "Error.";
|
||||
}
|
||||
that.enableItems();
|
||||
if(that.onchange) that.onchange();
|
||||
});
|
||||
this.enableItems();
|
||||
if(this.onchange) this.onchange();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.worker = OpenJsCad.javaScriptToSolidASync(this.script, paramValues, function(err, csg) {
|
||||
that.processing = false;
|
||||
that.worker = null;
|
||||
if(err)
|
||||
{
|
||||
that.setError(err);
|
||||
that.statusspan.innerHTML = "Error.";
|
||||
}
|
||||
else
|
||||
{
|
||||
that.solid = csg;
|
||||
if(that.viewer) that.viewer.setCsg(csg);
|
||||
that.validcsg = true;
|
||||
that.statusspan.innerHTML = "Ready.";
|
||||
}
|
||||
that.enableItems();
|
||||
if(that.onchange) that.onchange();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
hasSolid: function() {
|
||||
|
@ -496,6 +689,7 @@ OpenJsCad.Processor.prototype = {
|
|||
return this.processing;
|
||||
},
|
||||
|
||||
/*
|
||||
clearStl1: function() {
|
||||
if(this.hasstl)
|
||||
{
|
||||
|
@ -519,6 +713,7 @@ OpenJsCad.Processor.prototype = {
|
|||
if(this.onchange) this.onchange();
|
||||
}
|
||||
},
|
||||
*/
|
||||
|
||||
clearStl: function() {
|
||||
if(this.hasstl)
|
||||
|
@ -543,14 +738,14 @@ OpenJsCad.Processor.prototype = {
|
|||
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
|
||||
if(!window.requestFileSystem)
|
||||
{
|
||||
throw new Error("Your browser does not support the HTML5 FileSystem API");
|
||||
throw new Error("Your browser does not support the HTML5 FileSystem API. Please try the Chrome browser instead.");
|
||||
}
|
||||
if(!window.BlobBuilder)
|
||||
{
|
||||
throw new Error("Your browser does not support the HTML5 BlobBuilder API");
|
||||
throw new Error("Your browser does not support the HTML5 BlobBuilder API. Please try the Chrome browser instead.");
|
||||
}
|
||||
// create a random directory name:
|
||||
var dirname = "OpenJsCadStlOutput_"+parseInt(Math.random()*1000000000, 10)+".stl";
|
||||
var dirname = "OpenJsCadStlOutput1_"+parseInt(Math.random()*1000000000, 10)+".stl";
|
||||
var filename = this.filename+".stl";
|
||||
var that = this;
|
||||
window.requestFileSystem(TEMPORARY, 20*1024*1024, function(fs){
|
||||
|
@ -586,5 +781,112 @@ OpenJsCad.Processor.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
createParamControls: function() {
|
||||
this.parameterstable.innerHTML = "";
|
||||
this.paramControls = [];
|
||||
var paramControls = [];
|
||||
var tablerows = [];
|
||||
for(var i = 0; i < this.paramDefinitions.length; i++)
|
||||
{
|
||||
var errorprefix = "Error in parameter definition #"+(i+1)+": ";
|
||||
var paramdef = this.paramDefinitions[i];
|
||||
if(!('name' in paramdef))
|
||||
{
|
||||
throw new Error(errorprefix + "Should include a 'name' parameter");
|
||||
}
|
||||
var type = "text";
|
||||
if('type' in paramdef)
|
||||
{
|
||||
type = paramdef.type;
|
||||
}
|
||||
if( (type !== "text") && (type !== "int") && (type !== "float") && (type !== "choice") )
|
||||
{
|
||||
throw new Error(errorprefix + "Unknown parameter type '"+type+"'");
|
||||
}
|
||||
var control;
|
||||
if( (type == "text") || (type == "int") || (type == "float") )
|
||||
{
|
||||
control = document.createElement("input");
|
||||
control.type = "text";
|
||||
if('default' in paramdef)
|
||||
{
|
||||
control.value = paramdef.default;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( (type == "int") || (type == "float") )
|
||||
{
|
||||
control.value = "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
control.value = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == "choice")
|
||||
{
|
||||
if(!('values' in paramdef))
|
||||
{
|
||||
throw new Error(errorprefix + "Should include a 'values' parameter");
|
||||
}
|
||||
control = document.createElement("select");
|
||||
var values = paramdef.values;
|
||||
var captions;
|
||||
if('captions' in paramdef)
|
||||
{
|
||||
captions = paramdef.captions;
|
||||
if(captions.length != values.length)
|
||||
{
|
||||
throw new Error(errorprefix + "'captions' and 'values' should have the same number of items");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
captions = values;
|
||||
}
|
||||
var selectedindex = 0;
|
||||
for(var valueindex = 0; valueindex < values.length; valueindex++)
|
||||
{
|
||||
var option = document.createElement("option");
|
||||
option.value = values[valueindex];
|
||||
option.text = captions[valueindex];
|
||||
control.add(option);
|
||||
if('default' in paramdef)
|
||||
{
|
||||
if(paramdef.default == values[valueindex])
|
||||
{
|
||||
selectedindex = valueindex;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(values.length > 0)
|
||||
{
|
||||
control.selectedIndex = selectedindex;
|
||||
}
|
||||
}
|
||||
paramControls.push(control);
|
||||
var tr = document.createElement("tr");
|
||||
var td = document.createElement("td");
|
||||
var label = paramdef.name + ":";
|
||||
if('caption' in paramdef)
|
||||
{
|
||||
label = paramdef.caption;
|
||||
}
|
||||
|
||||
td.innerHTML = label;
|
||||
tr.appendChild(td);
|
||||
td = document.createElement("td");
|
||||
td.appendChild(control);
|
||||
tr.appendChild(td);
|
||||
tablerows.push(tr);
|
||||
}
|
||||
var that = this;
|
||||
tablerows.map(function(tr){
|
||||
that.parameterstable.appendChild(tr);
|
||||
});
|
||||
this.paramControls = paramControls;
|
||||
},
|
||||
|
||||
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue