github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/client/src/util.ts (about) 1 // Content managed by Project Forge, see [projectforge.md] for details. 2 export const appKey = "dbaudit"; 3 export const appName = "DB Audit"; 4 5 export function svgRef(key: string, size?: number, cls?: string): string { 6 if (!size) { 7 size = 18; 8 } 9 if (cls === undefined || cls === null) { 10 cls = "icon"; 11 } 12 return `<svg class="${cls}" style="width: ${size}px; height: ${size + "px"};"><use xlink:href="#svg-${key}"></use></svg>`; 13 } 14 15 export function svg(key: string, size?: number, cls?: string) { 16 return {"__html": svgRef(key, size, cls)}; 17 } 18 19 export function expandCollapse(extra?: string) { 20 if (!extra) { 21 extra = ""; 22 } 23 const e = svgRef("right", 15, "expand-collapse"); 24 return {"__html": e + extra}; 25 } 26 27 export function focusDelay(el: HTMLInputElement | HTMLTextAreaElement) { 28 setTimeout(() => { 29 el.setSelectionRange(el.value.length, el.value.length); 30 el.focus(); 31 }, 100); 32 return true; 33 }