1) {
var removeBtn = document.createElement("button");
removeBtn.className = "section-btn danger";
removeBtn.type = "button";
removeBtn.textContent = "Remove section";
removeBtn.addEventListener("click", function () {
if (!confirm('Remove "' + titleInput.value + '" and its charts? This cannot be undone.')) return;
card.remove();
renumberSections();
});
header.appendChild(removeBtn);
}
var frame = document.createElement("iframe");
frame.className = "section-frame";
frame.setAttribute("title", (title || ("Data " + n)) + " dashboard");
frame.srcdoc = templateHtml;
card.appendChild(header);
card.appendChild(frame);
container.appendChild(card);
renumberSections();
}
function renumberSections() {
Array.prototype.forEach.call(container.children, function (card, i) {
var badge = card.querySelector(".section-index");
if (badge) badge.textContent = String(i + 1);
});
}
document.getElementById("btnAddSection").addEventListener("click", function () { addSection(); });
addSection("Data 1");
})();