Skip to content

Commit

Permalink
add support for string type
Browse files Browse the repository at this point in the history
  • Loading branch information
couleurm committed Mar 25, 2024
1 parent 3ffd40a commit 3e87ab3
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ function V2loadParameters(funcName) {
if (checkbox.checked) {

if (!selected.includes(checkboxValue)) {
console.log("Adding " + checkboxValue)
// console.log("Adding " + checkboxValue)

selected.push(checkboxValue)
}
} else {

const index = selected.indexOf(checkboxValue);
if (index > -1) { // only splice array when item is found
console.log("Removing " + checkboxValue)
// console.log("Removing " + checkboxValue)

selected.splice(index, 1); // 2nd parameter means remove one item only
}
Expand All @@ -209,10 +209,12 @@ function V2loadParameters(funcName) {

parametersPane.appendChild(div)
}
parametersPane.appendChild(document.createElement("br"))

break
}
case 'bool': {
case 'bool':
case 'boolean': {
const checkbox = document.createElement("input")
checkbox.type = "checkbox"
checkbox.id = paramName
Expand All @@ -231,6 +233,33 @@ function V2loadParameters(funcName) {
parametersPane.appendChild(document.createElement("br"))
break
}
case 'String':
case 'string': {
const span = document.createElement("span")
span.innerHTML = paramName + ': '

const input = document.createElement("input")
input.type = "text"
input.id = paramName
span.appendChild(input)

const saved = getParameter('func_' + funcName, paramName)
if (![undefined, null, ""].includes(saved)) {
input.value = saved
}


input.addEventListener('input', function () {
writeParameter('func_' + funcName, paramName, input.value.trim())
});

span.appendChild(document.createElement("br"))

parametersPane.appendChild(span)
parametersPane.appendChild(document.createElement("br"))

break
}
default: {
console.log(param.type)
}
Expand All @@ -253,7 +282,7 @@ function sanitizeString(string) {
}

let doQuoting = false;
console.log(string)

if (string.includes(" ")) {
doQuoting = true
}
Expand Down Expand Up @@ -284,7 +313,13 @@ function exportCode() {

for (const arg in conf['func_' + funcName]) {
switch (tlui[funcName].parameters[arg].type) {
case 'String':
case 'string':
const string = sanitizeString(conf['func_' + funcName][arg])
if (string !== "") {
paragraph.innerHTML += ` -${arg} ${string}`
}
break
case 'enum':
paragraph.innerHTML += ` -${arg} ${sanitizeString(conf['func_' + funcName][arg])}`
break
Expand All @@ -294,12 +329,12 @@ function exportCode() {
paragraph.innerHTML += ` -${arg} ${values.map(string => sanitizeString(string)).join(', ')}`
}
break
case 'boolean':
case 'bool': {
if (
conf['func_' + funcName][arg]
) {
paragraph.innerHTML += ` -${arg}`

}
}
}
Expand Down

0 comments on commit 3e87ab3

Please sign in to comment.