20bbdbbfcf
- Extract CSS into public/css/{shared,players,courses}.css
- Extract JS into public/js/{chart,tooltips,progress,players,courses}.js
- Consolidate 5 duplicated tooltip blocks into setupTooltip() helper
- Add EJS view engine with layout partial and nav partial
- Convert HTML pages to EJS templates (index.ejs, courses.ejs)
- Add /courses route with redirect from /courses.html
- Remove old monolithic HTML files (1478 + 612 lines)
25 lines
798 B
JavaScript
25 lines
798 B
JavaScript
function setupTooltip(element, tooltip, getText) {
|
|
element.addEventListener('mouseenter', (e) => {
|
|
tooltip.textContent = getText();
|
|
tooltip.style.display = 'block';
|
|
tooltip.style.left = `${e.clientX + 15}px`;
|
|
tooltip.style.top = `${e.clientY - 35}px`;
|
|
});
|
|
|
|
element.addEventListener('mousemove', (e) => {
|
|
tooltip.style.left = `${e.clientX + 15}px`;
|
|
tooltip.style.top = `${e.clientY - 35}px`;
|
|
});
|
|
|
|
element.addEventListener('mouseleave', () => {
|
|
tooltip.style.display = 'none';
|
|
});
|
|
}
|
|
|
|
function replaceWithTooltip(element, tooltip, getText) {
|
|
const newElement = element.cloneNode(true);
|
|
element.parentNode.replaceChild(newElement, element);
|
|
setupTooltip(newElement, tooltip, getText);
|
|
return newElement;
|
|
}
|