Skip to content

Commit

Permalink
🐛 fix: Make sure that Leopard isn't loaded multiple times on the same…
Browse files Browse the repository at this point in the history
… page
  • Loading branch information
jolzee committed Nov 5, 2020
1 parent a19298d commit 28910e9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions public/static/embed-leopard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var leopardChatUi = (function () {

/* eslint-disable */
var leopardUrl;
var leopardLoaded = false;
var leopardEmbedSrc = null;
var leopardUrlRegex = /\[leopardUrl\]/g;
var teneoCtxParamsRegex = /\[teneoCtxParams\]/g;
Expand Down Expand Up @@ -190,11 +191,15 @@ var leopardChatUi = (function () {
}

function loadLeopard() {
var leopardTargetElement = document.getElementById("leopardChatWindow");
if (leopardTargetElement) {
leopardTargetElement.innerHTML = leopardChatTemplate;
} else {
document.body.insertAdjacentHTML("afterbegin", leopardChatTemplate);
if (!leopardLoaded) {
var leopardTargetElement = document.getElementById("leopardChatWindow");
if (leopardTargetElement) {
leopardTargetElement.innerHTML = leopardChatTemplate;
} else {
document.body.insertAdjacentHTML("afterbegin", leopardChatTemplate);
}
leopardLoaded = true;
document.removeEventListener('DOMContentLoaded', loadLeopard);
}
}

Expand Down

0 comments on commit 28910e9

Please sign in to comment.