mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 08:25:19 +01:00
re adding tcl to js converter utility.
This commit is contained in:
parent
817b3fe300
commit
04a6e518ec
1 changed files with 50 additions and 0 deletions
50
web/tcl.html
Normal file
50
web/tcl.html
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<style>
|
||||
textarea {
|
||||
width: calc(50% - 10px);
|
||||
height: calc(100% - 50px);
|
||||
}
|
||||
|
||||
</style>
|
||||
<h3>TCL to JSketcher OCC API converter</h3>
|
||||
<textarea id="tclIn" oninput="convertIt();"></textarea>
|
||||
<textarea id="jsOut"></textarea>
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
async function convertIt() {
|
||||
var lines = document.getElementById("tclIn").value.split('\n');
|
||||
const out = document.getElementById("jsOut");
|
||||
out.value = "";
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
out.value += await words(lines[i]) + '\n';
|
||||
}
|
||||
//alert("done");
|
||||
}
|
||||
|
||||
async function words(inputLine) {
|
||||
inputLine = inputLine.trim();
|
||||
if (inputLine == "") return "";
|
||||
var words = inputLine.trim().split(" ")
|
||||
|
||||
if (words[0].startsWith("#")) return "//" + inputLine;
|
||||
var returnLine = "oci." + words[0];
|
||||
returnLine += "(";
|
||||
for (var i = 1; i < words.length; i++) {
|
||||
//eliminate trailing commas.
|
||||
if (words[i].trim() !== "") {
|
||||
if (i == words.length - 1) {
|
||||
returnLine += `"` + words[i] + `"`;
|
||||
} else {
|
||||
returnLine += `"` + words[i] + `",`;
|
||||
}
|
||||
}
|
||||
}
|
||||
returnLine += ");";
|
||||
//console.log(returnLine);
|
||||
return returnLine
|
||||
}
|
||||
|
||||
</script>
|
||||
Loading…
Reference in a new issue