// assume jquery is already loaded console.log("loading 1"); var chatBot_n = #N#; var chatBot_interval = 1000; var chatBot_nInitial = chatBot_n; var chatBot_showActions = false; // workaround to get $ from wordpress version of jQuery jQuery(document).ready(function ($) { console.log("loading 2"); // bot styles (#1025978) $('head').append(''); // bootstrap function dynamicallyLoadScript(url) { var script = document.createElement("script"); script.src = url; document.head.appendChild(script); } // bootstrap js dynamicallyLoadScript('https://botcompany.de/1014036/raw/1025981?contentType=text/javascript'); // scripts for bot $(function(){ $("#addClass").click(function () { console.log("Opening chat bot"); $('#qnimate').addClass('popup-box-on'); $("#scrollme").scrollTop(1E10); return false; }); $("#removeClass").click(function () { $('#qnimate').removeClass('popup-box-on'); return false; }); }); function chatBot_showAction(action) { if (chatBot_showActions) { $("#actionMsg").html(action); $("#actionMsg").show(); } } window.chatBot_appendAction = function(action) { if (chatBot_showActions) { $("#actionMsg").append(" | " + action); $("#actionMsg").show(); } }; window.chatBot_hideAction = function() { $("#actionMsg").hide(); $("#actionMsg").html(""); }; window.chatBot_start = function() { url = "#INCREMENTALURL#"; if (url != '' && url != ("#INC" + "REMENTALURL#")) { chatBot_showAction("Loading " + url + chatBot_n); $.get(url + chatBot_n, function(src) { chatBot_showAction("Loaded"); var match = src.match(/\d+/); if (match != null) { chatBot_n = parseInt(match[0]); $(".direct-chat-messages").append(src); $("#scrollme").scrollTop(1E10); chatBot_showAction("Appended " + src.length); } else chatBot_showAction("chatBot_n=" + chatBot_n + " (initial=" + chatBot_nInitial + ")"); chatBot_appendAction("Rescheduling"); setTimeout(chatBot_start, chatBot_interval); chatBot_appendAction("Rescheduled"); }, 'text') .fail(function() { chatBot_showAction("Rescheduling after fail"); setTimeout(chatBot_start, chatBot_interval); }); } }; window.submitMsg = function() { if (status_message.value == 'new dialog') document.forms['msgform'].submit(); else { url = '#MSGURL#' + encodeURIComponent(status_message.value); chatBot_showAction('Submitting ' + url); $.get(url); status_message.value = ''; } }; $('body').append(`
Talk to chat bot