From 2a2303d1dccc120dd7aa5f6b6ade0f89e0064850 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 25 Nov 2025 07:42:23 +0000
Subject: [PATCH] =Feed block mostly good! Referrals look good to go. Ready for Madi and Heidi to approve

---
 assets/js/dash/UtilityFunctions.js |   48 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/assets/js/dash/UtilityFunctions.js b/assets/js/dash/UtilityFunctions.js
index ec64aac..566e1b1 100644
--- a/assets/js/dash/UtilityFunctions.js
+++ b/assets/js/dash/UtilityFunctions.js
@@ -127,7 +127,7 @@
  */
 window.getTemplate = function (template){
 	if (window.templates.size === 0) {
-		loadTemplates();
+		window.loadTemplates();
 	}
 	if(window.templates.has(template)){
 		return window.templates.get(template).cloneNode(true);
@@ -189,22 +189,25 @@
  * @param icon
  * @returns {Node | ActiveX.IXMLDOMNode}
  */
-window.getIcon = function getIcon(icon){
+window.icon = null;
+window.getIcon = function getIcon(icon, style = ''){
 	if (typeof icon === 'undefined') {
 		return '';
 	}
 
-
-	if(!window.jvbIcons){
-		window.jvbIcons = new Map();
+	if (!window.icon) {
+		window.icon = document.createElement('i');
+		window.icon.className = 'icon';
+		window.icon.ariaHidden = true;
 	}
-	if(!window.jvbIcons.has(icon) && jvbSettings.icons[icon]){
-		let temp = document.createElement('div');
-		temp.innerHTML = jvbSettings.icons[icon];
-		window.jvbIcons.set(icon, temp.firstElementChild.cloneNode(true));
-		temp.remove();
+	let theIcon = window.icon.cloneNode(true);
+	if (style !== '' && ['regular', 'bold', 'duotone', 'fill', 'light', 'thin' ].includes('style')) {
+		style = `-${style.slice(0, 2)}`;
+	} else {
+		style = '';
 	}
-	return window.jvbIcons.get(icon)?.cloneNode(true);
+	theIcon.classList.add(`icon-${icon}${style}`);
+	return theIcon;
 }
 
 /**
@@ -420,7 +423,22 @@
 window.showToast = function(message, type='success', actions={}){
 	window.jvbNotifications.showToast(message, type, actions);
 }
+window.dateFormatter = new Intl.DateTimeFormat('en-CA', {
+		year: 'numeric',
+		month: 'long',
+		day: 'numeric',
+		hour: '2-digit',
+		minute: '2-digit',
+		second: '2-digit',
+		timeZoneName: 'short'
+	});
 
+window.formatDate = function(date) {
+	if (!(date instanceof Date && !isNaN(date))) {
+		date = new Date(date);
+	}
+	return window.dateFormatter.format(date);
+}
 
 /**
  * Outputs the set text as if a typewriter were writing it
@@ -513,6 +531,9 @@
 }
 
 window.targetCheck = function (e, selector) {
+	if (Array.isArray(selector)) {
+		selector = selector.join(',');
+	}
 	if (typeof selector !== 'string') {
 		return false;
 	}
@@ -801,8 +822,6 @@
 
 	schedule(key, callback, delay = 1000) {
 		this.cancel(key);
-		console.log('Scheduling action: ', key);
-		console.log('With callback', callback);
 		this.timeouts.set(key, setTimeout(() => {
 			callback();
 			this.timeouts.delete(key);
@@ -811,7 +830,6 @@
 
 	cancel(key) {
 		if (this.timeouts.has(key)) {
-			console.log('Cancelling ', key);
 			clearTimeout(this.timeouts.get(key));
 			this.timeouts.delete(key);
 		}
@@ -819,11 +837,9 @@
 
 	cleanup() {
 		for (let timeout of this.timeouts.values()) {
-			console.log('clearing timeout: ', timeout);
 			clearTimeout(timeout);
 		}
 		this.timeouts.clear();
 	}
 }
 window.debouncer = new DebouncedActions();
-

--
Gitblit v1.10.0