From 73e58ae50d48f22b533c72fc3b883f861f3da7e6 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 15 Jun 2025 01:17:51 -0400 Subject: [PATCH] pattern for updating customizatoin functions established! also currently fixing bookmark form --- startpage.html | 59 +++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/startpage.html b/startpage.html index 9b83fb7..d9530ad 100644 --- a/startpage.html +++ b/startpage.html @@ -254,7 +254,7 @@ -
+
add new containers / layers
- -
add bookmarks
+
add bookmarks
@@ -2051,16 +2049,30 @@ * BOOK MARK HANDLERS * **********************/ - function addLink() { + function addLink(containerElement) { + let containerId = containerElement.id.split("-")[0]; + console.log(containerId); + let container = containerDataMap.get(containerId); + + /** + + + + change this to collect data directly from input.value + we aren't using a form anymore + + + **/ + // collect input data from form - const form = document.getElementById("bookmarkForm"); + const form = document.getElementById(containerId + "-bookmark-form"); const formData = new FormData(form); const label = formData.get("label"); let url = formData.get("url"); let section = formData.get("section"); - document.getElementById("linkInput").value = ""; - document.getElementById("labelInput").value = ""; + document.getElementById(containerId + "url-input").value = ""; + document.getElementById(containerId + "label-input").value = ""; // sanitize input if (!url.startsWith("http")) { @@ -2075,12 +2087,18 @@ } // save link (and if new, the section) - links.push({ - label: label, - url: url, - section: section, - }); + let tempIndex = Object.keys(container.sections).indexOf(section); + if (tempIndex =! -1) { + let tempSectionLinks = Object.values(container.sections)[tempIndex]; + tempSectionLinks.push({ + label: label, + url: url + }); + console.log(container.sections); + } + else { + } if (sections.indexOf(section) == -1) { sections.push(section); } @@ -2246,24 +2264,15 @@ ************************************/ function changeContainerBackground(colorChange) { - // DONT GET ELEMENT, GET CONTAINER FROM DATAMAP.... NEED TO FIX FOR INIT ANYWAYS - let container = document.getElementById( - colorChange.currentTarget.id.split("-")[0] - ); + let containerId = colorChange.currentTarget.id.split("-")[0]; + let container = containerDataMap.get(containerId); container.containerSettings.backgroundRgba = hexToRgba( document.getElementById(container.id + "-settings-bg-color").value, document.getElementById(container.id + "-settings-bg-alpha").value ); -/* container.containerSettings.backgroundRgba = hexToRgba( - document.getElementById("containerColorPicker").value, - document.getElementById("containerAlpha").value - ); - document.getElementById("mainContainer").style.backgroundColor = - containerSettings.backgroundRgba; -*/ - container.style.backgroundColor = + document.getElementById(containerId).style.backgroundColor = container.containerSettings.backgroundRgba; }