File size: 919 Bytes
c31821c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
export function initControlNetModals(container) {
    // Get all the buttons that open a modal
    const btns = container.querySelectorAll(".cnet-modal-open");

    // Get all the <span> elements that close a modal
    const spans = container.querySelectorAll(".cnet-modal-close");

    // For each button, add a click event listener that opens the corresponding modal
    btns.forEach((btn) => {
        const modalId = btn.id.replace('cnet-modal-open-', '');
        const modal = container.querySelector("#cnet-modal-" + modalId);
        btn.addEventListener('click', () => {
            modal.style.display = "block";
        });
    });

    // For each <span> element, add a click event listener that closes the corresponding modal
    spans.forEach((span) => {
        const modal = span.parentNode;
        span.addEventListener('click', () => {
            modal.style.display = "none";
        });
    });
}