import { appGlobals } from './globals.js' import { wasmPntrToJsString, wasmPntrAndLengthToJsString } from './wasm_functions.js' export function jsSetLabel(labelIdStrPntr, labelStrPntr) { let labelIdStr = wasmPntrToJsString(labelIdStrPntr); let labelStr = wasmPntrToJsString(labelStrPntr); var labelContainer = document.getElementById("label_container"); if (labelContainer != null) { var foundExistingLabel = false; var existingLabels = labelContainer.getElementsByClassName("wasm_label"); if (existingLabels != null) { for (var lIndex = 0; lIndex < existingLabels.length; lIndex++) { if (existingLabels[lIndex].id == labelIdStr) { existingLabels[lIndex].textContent = labelStr; foundExistingLabel = true; break; } } } if (!foundExistingLabel) { const newLabel = document.createElement("p"); newLabel.className = "wasm_label"; newLabel.id = labelIdStr; newLabel.textContent = labelStr; labelContainer.appendChild(newLabel); } } else { console.error("Failed to file container with id \"label_container\"!"); } } export let jsMiscFunctions = { jsSetLabel: jsSetLabel, };