@meetelise/chat 1.43.31 → 1.43.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -59,6 +59,10 @@ import { updateRentgrataToken } from "../rentgrata";
|
|
|
59
59
|
import { WidgetType } from "../main/MEChat";
|
|
60
60
|
import { logCdnVersion } from "../logCdnVersion";
|
|
61
61
|
import { replaceSelectButtonsWithNewLink } from "../replaceSelectButtonsWithNewLink";
|
|
62
|
+
import {
|
|
63
|
+
overwriteCheckAvail,
|
|
64
|
+
shouldOverwriteCheckAvail,
|
|
65
|
+
} from "../overwriteCheckAvailability";
|
|
62
66
|
|
|
63
67
|
import "./chat-additional-actions";
|
|
64
68
|
import { LeadSourceMultitouchClient } from "./LeadSourceMultitouchClient";
|
|
@@ -538,6 +542,19 @@ export class MEChat extends LitElement {
|
|
|
538
542
|
});
|
|
539
543
|
}
|
|
540
544
|
}
|
|
545
|
+
|
|
546
|
+
if (
|
|
547
|
+
this.buildingSlug &&
|
|
548
|
+
!!this.buildingWebchatView?.isLiveOnApplications &&
|
|
549
|
+
this.buildingWebchatView?.applicationLink &&
|
|
550
|
+
shouldOverwriteCheckAvail(this.orgSlug)
|
|
551
|
+
) {
|
|
552
|
+
overwriteCheckAvail(
|
|
553
|
+
this.orgSlug,
|
|
554
|
+
this.buildingSlug,
|
|
555
|
+
this.buildingWebchatView.applicationLink
|
|
556
|
+
);
|
|
557
|
+
}
|
|
541
558
|
};
|
|
542
559
|
|
|
543
560
|
private initializeChatVariables = async (): Promise<void> => {
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { LogType, sendLoggingEvent } from "./analytics";
|
|
2
|
+
|
|
3
|
+
// Note. please update accordingly. this was a one off solution for a specific building
|
|
4
|
+
export const shouldOverwriteCheckAvail = (orgSlug: string): boolean => {
|
|
5
|
+
return orgSlug === "c954426c-12ab-4f8e-8384-8218e79eaf72";
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const OVERWRITE_BUTTON_LABELS = ["Check Availability", "Apply Now"];
|
|
9
|
+
|
|
10
|
+
const isCheckAvailAnchor = (element: HTMLAnchorElement): boolean => {
|
|
11
|
+
if (!element.classList.contains("floorplan-button")) return false;
|
|
12
|
+
|
|
13
|
+
const spans = element.getElementsByTagName("span");
|
|
14
|
+
if (spans.length !== 1) return false;
|
|
15
|
+
|
|
16
|
+
const text = spans[0].textContent?.trim();
|
|
17
|
+
return text != null && OVERWRITE_BUTTON_LABELS.includes(text);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const overwriteElement = (
|
|
21
|
+
element: HTMLAnchorElement,
|
|
22
|
+
applicationLink: string,
|
|
23
|
+
orgSlug: string,
|
|
24
|
+
buildingSlug: string
|
|
25
|
+
): boolean => {
|
|
26
|
+
if (!isCheckAvailAnchor(element)) return false;
|
|
27
|
+
if (element.getAttribute("href") === applicationLink) return false;
|
|
28
|
+
|
|
29
|
+
const oldHref = element.getAttribute("href");
|
|
30
|
+
element.setAttribute("href", applicationLink);
|
|
31
|
+
element.setAttribute("target", "_blank");
|
|
32
|
+
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.log("overwrite check avail");
|
|
35
|
+
|
|
36
|
+
sendLoggingEvent({
|
|
37
|
+
logTitle: "CHECK_AVAIL_OVERWRITE",
|
|
38
|
+
logData: {
|
|
39
|
+
oldHref,
|
|
40
|
+
newHref: applicationLink,
|
|
41
|
+
website: window.location.href,
|
|
42
|
+
},
|
|
43
|
+
logType: LogType.info,
|
|
44
|
+
buildingSlug,
|
|
45
|
+
orgSlug,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return true;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const overwriteExistingElements = (
|
|
52
|
+
applicationLink: string,
|
|
53
|
+
orgSlug: string,
|
|
54
|
+
buildingSlug: string
|
|
55
|
+
): void => {
|
|
56
|
+
const anchors = document.body.getElementsByTagName("a");
|
|
57
|
+
for (let i = 0; i < anchors.length; i++) {
|
|
58
|
+
overwriteElement(anchors[i], applicationLink, orgSlug, buildingSlug);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const processAddedNodes = (
|
|
63
|
+
nodes: NodeList,
|
|
64
|
+
applicationLink: string,
|
|
65
|
+
orgSlug: string,
|
|
66
|
+
buildingSlug: string
|
|
67
|
+
): void => {
|
|
68
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
69
|
+
const node = nodes[i];
|
|
70
|
+
if (node.nodeType !== Node.ELEMENT_NODE) continue;
|
|
71
|
+
|
|
72
|
+
const el = node as Element;
|
|
73
|
+
if (el.tagName === "A") {
|
|
74
|
+
overwriteElement(
|
|
75
|
+
el as HTMLAnchorElement,
|
|
76
|
+
applicationLink,
|
|
77
|
+
orgSlug,
|
|
78
|
+
buildingSlug
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const nested = el.getElementsByTagName("a");
|
|
83
|
+
for (let j = 0; j < nested.length; j++) {
|
|
84
|
+
overwriteElement(nested[j], applicationLink, orgSlug, buildingSlug);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const overwriteCheckAvail = (
|
|
90
|
+
orgSlug: string,
|
|
91
|
+
buildingSlug: string,
|
|
92
|
+
applicationLink: string
|
|
93
|
+
): void => {
|
|
94
|
+
overwriteExistingElements(applicationLink, orgSlug, buildingSlug);
|
|
95
|
+
|
|
96
|
+
const observer = new MutationObserver((mutations) => {
|
|
97
|
+
for (const mutation of mutations) {
|
|
98
|
+
processAddedNodes(
|
|
99
|
+
mutation.addedNodes,
|
|
100
|
+
applicationLink,
|
|
101
|
+
orgSlug,
|
|
102
|
+
buildingSlug
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
108
|
+
};
|