1717 *
1818 * ENGRID PAGE TEMPLATE ASSETS
1919 *
20- * Date: Wednesday, April 29 , 2026 @ 09:20:39 ET
20+ * Date: Thursday, May 14 , 2026 @ 12:11:14 ET
2121 * By: michael
2222 * ENGrid styles: v0.25.0
2323 * ENGrid scripts: v0.25.1
@@ -28045,9 +28045,31 @@ class GiftHistory {
2804528045 return node.nodeType === Node.ELEMENT_NODE && node.classList.contains(className);
2804628046 }
2804728047
28048+ parseISODate(dateString) {
28049+ const parts = dateString.split("-").map(Number);
28050+ return {
28051+ year: parts[0],
28052+ month: parts[1],
28053+ day: parts[2]
28054+ };
28055+ }
28056+
28057+ dateToComparable(dateString) {
28058+ // Handles both "yyyy-MM-dd" and "MM/dd/yyyy" formats
28059+ if (dateString.includes("-")) {
28060+ const parts = dateString.split("-").map(Number);
28061+ return parts[0] * 10000 + parts[1] * 100 + parts[2];
28062+ } else {
28063+ const parts = dateString.split("/").map(Number);
28064+ return parts[2] * 10000 + parts[0] * 100 + parts[1];
28065+ }
28066+ }
28067+
2804828068 renderMergedGiftHistory() {
2804928069 const transactionsList = document.querySelector(".en__hubTxnGiving__transactions__list");
28050- transactionsList?.removeAttribute("data-engrid-transactions-loaded");
28070+ transactionsList?.removeAttribute("data-engrid-transactions-loaded"); // Remove previously inserted remote gifts to avoid duplication on pagination
28071+
28072+ transactionsList?.querySelectorAll(".en__hubTxnGiving__transaction--remote").forEach(el => el.remove());
2805128073 const enGiftHistory = this.getENGiftHistoryOnPage();
2805228074 const giftHistoryToRender = this.mergeRemoteGiftHistoryEntries(enGiftHistory);
2805328075 this.addGiftHistoryToDOM(giftHistoryToRender);
@@ -28081,19 +28103,19 @@ class GiftHistory {
2808128103 const onFirstPage = document.querySelector(".en__pagination__prev")?.hasAttribute("disabled");
2808228104 const onLastPage = document.querySelector(".en__pagination__next")?.hasAttribute("disabled");
2808328105 const transactionsDate = document.getElementById("en__hubTxnGiving__transactions__date__select")?.value;
28084- let remoteGiftHistoryToMerge;
28106+ let remoteGiftHistoryToMerge = [] ;
2808528107
2808628108 if (enGiftHistory.length > 0) {
2808728109 //if the page has gifts, we want to merge in remote gifts based on the date range of the gifts on the page
28088- const mostRecentENGift = Date.parse (enGiftHistory[0].date);
28089- const oldestENGift = Date.parse (enGiftHistory[enGiftHistory.length - 1].date);
28110+ const mostRecentENGift = this.dateToComparable (enGiftHistory[0].date);
28111+ const oldestENGift = this.dateToComparable (enGiftHistory[enGiftHistory.length - 1].date);
2809028112 remoteGiftHistoryToMerge = this.remoteGiftHistory.filter(remoteGift => {
2809128113 //If we're on the first page, merge in gifts that are newer than the oldest gift on the page
2809228114 //If we're on the last page, merge in gifts that are older than the most recent gift on the page
2809328115 //Otherwise, we want to merge in all gifts between the oldest and most recent gifts on the page
2809428116 //Also, make sure the year is the same as the year filter (or "all time");
28095- const giftYearMatchesOrAllTime = transactionsDate === "0" || transactionsDate === new Date (remoteGift.date).getFullYear() .toString();
28096- const remoteGiftDate = Date.parse (remoteGift.date);
28117+ const giftYearMatchesOrAllTime = transactionsDate === "0" || transactionsDate === this.parseISODate (remoteGift.date).year .toString();
28118+ const remoteGiftDate = this.dateToComparable (remoteGift.date);
2809728119
2809828120 if (onFirstPage) {
2809928121 return remoteGiftDate >= oldestENGift && giftYearMatchesOrAllTime;
@@ -28104,19 +28126,18 @@ class GiftHistory {
2810428126 return remoteGiftDate >= oldestENGift && remoteGiftDate <= mostRecentENGift && giftYearMatchesOrAllTime;
2810528127 });
2810628128 } else {
28107- // If we don't have any gifts on the page, we want to merge in remote gifts based on the date filter
2810828129 remoteGiftHistoryToMerge = this.remoteGiftHistory.filter(remoteGift => {
2810928130 // If the date filter is set to "All time", merge in all gifts
2811028131 if (transactionsDate === "0") {
2811128132 return true;
2811228133 } // Otherwise, merge in gifts that match the year of the date filter
2811328134
2811428135
28115- return new Date (remoteGift.date).getFullYear() === parseInt(transactionsDate);
28136+ return this.parseISODate (remoteGift.date).year === parseInt(transactionsDate);
2811628137 });
2811728138 }
2811828139
28119- return [...enGiftHistory, ...remoteGiftHistoryToMerge].sort((a, b) => Date.parse (b.date) - Date.parse (a.date));
28140+ return [...enGiftHistory, ...remoteGiftHistoryToMerge].sort((a, b) => this.dateToComparable (b.date) - this.dateToComparable (a.date));
2812028141 }
2812128142
2812228143 updateTotalAmountDonated() {
@@ -28133,8 +28154,7 @@ class GiftHistory {
2813328154 // The value of the year select is a year like "2023".
2813428155 // Filter the remote gift history to only include gifts from that year and then sum the USD values
2813528156 remoteTotal = this.remoteGiftHistory.filter(gift => {
28136- const giftDate = new Date(gift.date);
28137- return giftDate.getFullYear() === parseInt(transactionsDate);
28157+ return this.parseISODate(gift.date).year === parseInt(transactionsDate);
2813828158 }).reduce((total, gift) => {
2813928159 return total + parseFloat(gift.amount);
2814028160 }, 0);
@@ -28207,8 +28227,8 @@ class GiftHistory {
2820728227 break;
2820828228 }
2820928229
28210- const date = new Date (gift.date);
28211- const formattedDate = `${date.getMonth() + 1 }/${date.getDate() }/${date.getFullYear() }`;
28230+ const date = this.parseISODate (gift.date);
28231+ const formattedDate = `${date.month }/${date.day }/${date.year }`;
2821228232 const formattedAmount = parseFloat(gift.amount.toString()).toFixed(2);
2821328233 giftEl.innerHTML = `
2821428234 <div class="en__hubTxnGiving__transaction__header">
0 commit comments