- Implemented a new Player class in player.js to handle audio playback, including HLS support using hls.js. - Created a shared API module in api.js for making HTTP requests with proper error handling. - Added DOM utility functions in dom.js for creating and clearing elements. - Introduced WebSocket connection handling in ws.js for real-time updates. - Developed a comprehensive CSS stylesheet for styling the application, including a high-contrast theme.
18 lines
796 B
JavaScript
18 lines
796 B
JavaScript
export function el(tag, props = {}, ...children) {
|
|
const node = document.createElement(tag);
|
|
for (const [k, v] of Object.entries(props || {})) {
|
|
if (k === 'class') node.className = v;
|
|
else if (k === 'style' && typeof v === 'object') Object.assign(node.style, v);
|
|
else if (k.startsWith('on') && typeof v === 'function') node.addEventListener(k.slice(2).toLowerCase(), v);
|
|
else if (k === 'html') node.innerHTML = v;
|
|
else if (v !== false && v != null) node.setAttribute(k, v === true ? '' : v);
|
|
}
|
|
for (const c of children.flat()) {
|
|
if (c == null || c === false) continue;
|
|
node.appendChild(c instanceof Node ? c : document.createTextNode(String(c)));
|
|
}
|
|
return node;
|
|
}
|
|
|
|
export function clear(node) { while (node.firstChild) node.removeChild(node.firstChild); }
|