');setTimeout(iwcCheatHeartbeat,30000); break; case "TEMPLATE": messageItemContainer = $('
'); break; default: console.log("MessageType not supported", messageType) } if (messageItemContainer != null) { chatContainer.append(messageItemContainer); } }); /* Scroll down */ chatContainer.animate({ scrollTop: chatContainer.prop("scrollHeight") }, 500);}function iwcChatControl(showChat=true, showChatInput=true, chatInputId="", notifyCount="") { if (showChat) { $("#OPEN_NOW_CHAT").hide(); $("#NOW_CHAT_CHATBOX").show(); } else { $("#OPEN_NOW_CHAT").show(); $("#NOW_CHAT_CHATBOX").hide(); if (notifyCount != "") { $("#OPEN_NOW_CHAT .now-chat-badge").html(notifyCount); $("#OPEN_NOW_CHAT .now-chat-badge").show(); $(".sticky-footer-mobile .icon-element.btn-chat .badge").html(notifyCount); $(".sticky-footer-mobile .icon-element.btn-chat .badge").show(); } else { $("#OPEN_NOW_CHAT .now-chat-badge").hide(); $(".sticky-footer-mobile .icon-element.btn-chat .badge").hide(); } } if (showChatInput) { $("#NOW_CHAT_CHATBOX_CONTAINER").show(); $("#USER_MESSAGE").val(""); $("#USER_MESSAGE").attr("data-chat-input-id", chatInputId); setTimeout(function(){ $("#USER_MESSAGE").get(0).focus(); }, 200); } else { $("#NOW_CHAT_CHATBOX_CONTAINER").hide(); }}/*handle postMessage*/window.addEventListener( "message", (event) => { let eventData = event.data || ""; if ( typeof eventData == 'object'){ eventData = JSON.stringify(eventData); } if ( event.origin.includes(".winkler.de") || event.origin.includes(".winkler.com") ){ let requestURL = iwcChatGetRequestURL( "HANDLE_JS_POST_MESSAGE" ); $.ajax({ url: requestURL, method: "POST", data: eventData, beforeSend: function(xhr) {} }).done(function(data) { console.log("iwcChatHandleJSPostMessage", data); }).fail(function(jqXHR, textStatus) { console.error("iwcChatHandleJSPostMessage", "Request failed: " + textStatus); }); } else { console.error("wrong origin from postMessage", event); } });function getMobileOperatingSystem() { var userAgent = navigator.userAgent || navigator.vendor || window.opera; /* Windows Phone must come first because its UA also contains "Android" */ if (/windows phone/i.test(userAgent)) { return "WINDOWS_PHONE"; } if (/android/i.test(userAgent)) { return "ANDROID"; } if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) { return "IOS"; } return "unknown";}