-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aecf625
commit c4a5bdc
Showing
4 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
function loadIntercom() { | ||
(function () { | ||
const w: any = window; | ||
const ic = w.Intercom; | ||
if (typeof ic === "function") { | ||
ic("reattach_activator"); | ||
ic("update", w.intercomSettings); | ||
} else { | ||
const d = document; | ||
const i = function () { | ||
i.c(arguments); | ||
}; | ||
i.q = []; | ||
i.c = function (args) { | ||
i.q.push(args); | ||
}; | ||
w.Intercom = i; | ||
const s = d.createElement("script"); | ||
s.type = "text/javascript"; | ||
s.async = true; | ||
s.src = "https://widget.intercom.io/widget/rxsoqwkv"; | ||
const x = d.getElementsByTagName("script")[0]; | ||
if (x && x.parentNode) { | ||
x.parentNode.insertBefore(s, x); | ||
console.log("intercom loading."); | ||
} | ||
} | ||
})(); | ||
} | ||
|
||
function checkAndLoadIntercom() { | ||
if (document.readyState === "complete") { | ||
// Wait 15 seconds after document ready and network idle | ||
setTimeout(loadIntercom, 15000); | ||
} | ||
} | ||
|
||
// Check for document ready and network idle | ||
if (document.readyState === "complete") { | ||
checkAndLoadIntercom(); | ||
} else { | ||
window.addEventListener("load", checkAndLoadIntercom, false); | ||
} |