// JavaScript to close the "Add Link" modal
function closeModal() {
var modal = document.getElementById("myModal");
modal.style.display = "none";
}
// JavaScript to add or modify a link
function addOrModifyLink() {
var linkName = document.getElementById("link-name").value;
var linkUrl = document.getElementById("link-url").value;
var linkContainer = document.querySelector(".link-container");
var modal = document.getElementById("myModal");
var link = document.querySelector(".link.editing");
if (link) {
link.querySelector("a").innerText = linkName;
link.querySelector("a").href = linkUrl;
link.classList.remove("editing");
} else {
var newLink = document.createElement("div");
newLink.classList.add("link");
newLink.innerHTML =
'' + linkName + '' +
'' +
'';
linkContainer.appendChild(newLink);
}
modal.style.display = "none";
}
// JavaScript to delete a link
function deleteLink(link) {
var linkContainer = document.querySelector(".link-container");
linkContainer.removeChild(link);
}