MCPcopy
hub / github.com/stemdeckapp/stemdeck / _makeSectionEl

Function _makeSectionEl

static/js/sections.js:73–105  ·  view source on GitHub ↗
(section)

Source from the content-addressed store, hash-verified

71}
72
73function _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
107function _esc(str) {
108 return String(str)

Callers 1

_renderFunction · 0.85

Calls 5

_escFunction · 0.85
_deleteSectionFunction · 0.85
_openRenameFunction · 0.85
_wireDragFunction · 0.85
_wireResizeFunction · 0.85

Tested by

no test coverage detected