(section)
| 71 | } |
| 72 | |
| 73 | function _makeSectionEl(section) { |
| 74 | const pctStart = (section.start / _duration) * 100; |
| 75 | const pctWidth = ((section.end - section.start) / _duration) * 100; |
| 76 | |
| 77 | const el = document.createElement("div"); |
| 78 | el.className = "section-block"; |
| 79 | el.dataset.id = section.id; |
| 80 | el.style.cssText = `left:${pctStart.toFixed(4)}%;width:${pctWidth.toFixed(4)}%;--sc:${section.color}`; |
| 81 | |
| 82 | el.innerHTML = ` |
| 83 | <div class="section-handle section-handle-l" data-edge="left"></div> |
| 84 | <span class="section-label">${_esc(section.name)}</span> |
| 85 | <button class="section-del" type="button" aria-label="Delete section" tabindex="-1">×</button> |
| 86 | <div class="section-handle section-handle-r" data-edge="right"></div> |
| 87 | `; |
| 88 | |
| 89 | el.querySelector(".section-del").addEventListener("click", (e) => { |
| 90 | e.stopPropagation(); |
| 91 | _deleteSection(section.id); |
| 92 | }); |
| 93 | |
| 94 | el.querySelector(".section-label").addEventListener("dblclick", (e) => { |
| 95 | e.stopPropagation(); |
| 96 | _openRename(section.id, el.querySelector(".section-label")); |
| 97 | }); |
| 98 | |
| 99 | _wireDrag(el, section); |
| 100 | for (const h of el.querySelectorAll(".section-handle")) { |
| 101 | _wireResize(h, el, section); |
| 102 | } |
| 103 | |
| 104 | return el; |
| 105 | } |
| 106 | |
| 107 | function _esc(str) { |
| 108 | return String(str) |
no test coverage detected