| 1246 | } |
| 1247 | |
| 1248 | function setLabelTexts(selector, values) { |
| 1249 | document.querySelectorAll(selector).forEach((element, index) => { |
| 1250 | const value = values[index]; |
| 1251 | if (value === undefined) return; |
| 1252 | const node = Array.from(element.childNodes).find((child) => child.nodeType === Node.TEXT_NODE && child.textContent.trim()); |
| 1253 | if (!node) { |
| 1254 | element.appendChild(document.createTextNode(` ${value}`)); |
| 1255 | return; |
| 1256 | } |
| 1257 | const prefix = node.previousSibling ? " " : ""; |
| 1258 | const suffix = node.nextSibling ? " " : ""; |
| 1259 | node.textContent = `${prefix}${value}${suffix}`; |
| 1260 | }); |
| 1261 | } |
| 1262 | |
| 1263 | function setAttr(selector, attr, value) { |
| 1264 | const element = document.querySelector(selector); |