Skip to content

Instantly share code, notes, and snippets.

@gregblass
Created October 14, 2020 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregblass/0b0d27d9fa03d48663d562eb84e048c8 to your computer and use it in GitHub Desktop.
Save gregblass/0b0d27d9fa03d48663d562eb84e048c8 to your computer and use it in GitHub Desktop.
LiveChat 2.0 + Turbolinks 5
function loadChat(group = 0) {
window.__lc = window.__lc || {};
window.__lc.license = ########;
;(function(n,t,c){function i(n){return e._h?e._h.apply(null,n):e._q.push(n)}var e={_q:[],_h:null,_v:"2.0",on:function(){i(["on",c.call(arguments)])},once:function(){i(["once",c.call(arguments)])},off:function(){i(["off",c.call(arguments)])},get:function(){if(!e._h)throw new Error("[LiveChatWidget] You can't use getters before load.");return i(["get",c.call(arguments)])},call:function(){i(["call",c.call(arguments)])},init:function(){var n=t.createElement("script");n.async=!0,n.type="text/javascript",n.src="https://cdn.livechatinc.com/tracking.js",t.head.appendChild(n)}};!n.__lc.asyncInit&&e.init(),n.LiveChatWidget=n.LiveChatWidget||e}(window,document,[].slice))
}
function initChat() {
if (typeof LC_API !== 'undefined' && !LC_API.chat_running()) {
LiveChatWidget.call('destroy');
}
loadChat();
}
$(document).on("turbolinks:load", function() {
initChat();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment