* Helper function to inject the translated text and tooltip. * * @param {string} id ID of the HTML element * @param {string} attribute Name of the attribute used for localization * @param {string} tooltip
(id, attribute, tooltip = "")
| 324 | * @param {string} tooltip |
| 325 | */ |
| 326 | function injectText(id, attribute, tooltip = "") { |
| 327 | let object = document.getElementById(id); |
| 328 | object.textContent = translate(attribute); |
| 329 | |
| 330 | /* |
| 331 | This function will throw an error if no translation |
| 332 | is found for the tooltip. This is a planned error. |
| 333 | */ |
| 334 | tooltip = translate(attribute + "_title"); |
| 335 | |
| 336 | if (tooltip !== "") { |
| 337 | object.setAttribute('title', tooltip); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Set the value of a switch button. |