From a24a06002081ad71a78ffeff9072725ba39cf121 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 17 Feb 2026 20:05:31 +0000
Subject: [PATCH] =minor changes, particularly around the JVB_CHILD_URL pattern

---
 assets/js/concise/UtilityFunctions.js |   56 ++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/assets/js/concise/UtilityFunctions.js b/assets/js/concise/UtilityFunctions.js
index 2381056..8272c31 100644
--- a/assets/js/concise/UtilityFunctions.js
+++ b/assets/js/concise/UtilityFunctions.js
@@ -413,26 +413,40 @@
 	}
 }
 
-window.prefixInput = function(input, prefix, replace = false) {
-	let newId = replace ? prefix : `${prefix}${input.name}`;
-	if (input.labels.length > 0) {
-		input.labels?.forEach(label => {
-			label.htmlFor = newId;
-		});
+window.prefixInput = function(input, prefix, wrapper = null, replace = false, name = false) {
+	if (!input) {
+		console.warn('prefixInput called with null/undefined input');
+		return;
+	}
+	const oldId = input.id;
+	const newId = replace ? prefix : `${prefix}${input.name}`;
+
+	// Search for label within wrapper if provided, otherwise use existing logic
+	let label = null;
+
+	if (wrapper) {
+		// Most reliable: search within wrapper by old ID
+		label = wrapper.querySelector(`label[for="${oldId}"]`);
+	} else if (input.labels && input.labels.length > 0) {
+		// Fallback to input.labels if no wrapper provided
+		label = input.labels[0];
+	} else if (input.previousElementSibling?.tagName === 'LABEL') {
+		label = input.previousElementSibling;
+	} else if (input.nextElementSibling?.tagName === 'LABEL') {
+		label = input.nextElementSibling;
 	} else {
-		if (input.nextElementSibling?.tagName === 'LABEL') {
-			input.nextElementSibling.htmlFor = newId;
-		}else if (input.previousElementSibling?.tagName === 'LABEL') {
-			input.previousElementSibling.htmlFor = newId;
-		} else {
-			let label = input.parentElement.querySelector(`label[for="${input.id}"]`);
-			if (label) {
-				label.htmlFor = newId;
-			}
-		}
+		// Final fallback: search up the tree
+		label = input.closest('[data-field]')?.querySelector(`label[for="${oldId}"]`);
+	}
+
+	if (label) {
+		label.htmlFor = newId;
 	}
 
 	input.id = newId;
+	if (name) {
+		input.name = newId;
+	}
 }
 
 /**
@@ -983,3 +997,13 @@
 updateMaxScroll();
 updateScrollProgress(lastY);
 
+
+
+window.decodeHTMLEntities = function(text) {
+	if (!window.decodeHelper) {
+		window.decodeHelper = document.createElement('textarea');
+	}
+
+	window.decodeHelper.innerHTML = text;
+	return window.decodeHelper.value;
+}

--
Gitblit v1.10.0