| 12 | // find all platform-specific *block* elements and hide or show as appropriate |
| 13 | // example: {% webui %} block content {% endwebui %} |
| 14 | function showToolSpecificContent(tool: string, supportedTools: Array<string>) { |
| 15 | const markdowns = Array.from(document.querySelectorAll<HTMLElement>('.extended-markdown')) |
| 16 | markdowns |
| 17 | .filter((el) => supportedTools.some((tool) => el.classList.contains(tool))) |
| 18 | .forEach((el) => { |
| 19 | el.style.display = el.classList.contains(tool) ? '' : 'none' |
| 20 | }) |
| 21 | |
| 22 | // find all tool-specific *inline* elements and hide or show as appropriate |
| 23 | // example: <span class="tool-webui">inline content</span> |
| 24 | const toolEls = Array.from( |
| 25 | document.querySelectorAll<HTMLElement>(supportedTools.map((tool) => `.tool-${tool}`).join(', ')) |
| 26 | ) |
| 27 | toolEls.forEach((el) => { |
| 28 | el.style.display = el.classList.contains(`tool-${tool}`) ? '' : 'none' |
| 29 | }) |
| 30 | } |
| 31 | |
| 32 | function getDefaultTool(defaultTool: string | undefined, detectedTools: Array<string>): string { |
| 33 | // If there is a default tool and the tool is present on this page |