(function(){
// Localize jQuery variable
var jumpQuery;
if(location.hostname.indexOf('myjumper.store') > -1){
var bho_BASE_URL_lib = "//"+ location.hostname +"/";
var bho_BASE_URL = "//"+ location.hostname +"/";
var bho_IS_LIVE = false;
}
else if(location.hostname.indexOf('jumper') > -1 && location.hostname.indexOf('appspot.com') > -1){
var bho_BASE_URL_lib = "//"+ location.hostname +"/";
var bho_BASE_URL = "//"+ location.hostname +"/";
if(location.hostname.indexOf('appspot.com') > -1){
var bho_IS_LIVE = false;
}
else{
var bho_IS_LIVE = true;
}
}
else if(location.hostname.indexOf('localhost') > -1){
var bho_BASE_URL_lib = "//localhost:11080/";
var bho_BASE_URL = "//jumper.ai/";
var bho_IS_LIVE = true;
}
else if(location.hostname.indexOf('jumpertest.ai') > -1){
var bho_BASE_URL_lib = "//"+ location.hostname +"/";
var bho_BASE_URL = "//jumpertest.ai/";
var bho_IS_LIVE = false;
}
else{
var bho_BASE_URL_lib = "//jumper.ai/";
var bho_BASE_URL = "//jumper.ai/";
var bho_IS_LIVE = true;
}
var bho_MAIN_URL = bho_BASE_URL +"api/";
if(bho_IS_LIVE == true){
var bho_PUSHER_KEY = "3f548002d8b9f7c45559";
var bho_PUSHER_CLUSTER = "us2";
}
else{
var bho_PUSHER_KEY = "5e407795bf6b8d3286b3";
var bho_PUSHER_CLUSTER = "us2";
}
/******** Load jQuery if not present *********/
var script_tag = document.createElement('script');
script_tag.setAttribute("type","text/javascript");
script_tag.setAttribute("src", bho_BASE_URL_lib +"widget/js/jquery-and-cookie.min.js");
if(script_tag.readyState){
script_tag.onreadystatechange = function(){ // For old versions of IE
if(this.readyState == 'complete' || this.readyState == 'loaded'){
scriptLoadHandler();
}
else{
//console.log("jquery.min.js not found");
}
};
}
else{
script_tag.onload = scriptLoadHandler;
}
// Try to find the head, otherwise default to the documentElement
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
/******** Called once jQuery has loaded ******/
function scriptLoadHandler(){
// Restore $ and window.jQuery to their previous values and store the
// new jumpQuery in our local jQuery variable
jumpQuery = window.jQuery.noConflict(true);
bhoSdkMain();
}
var jumperWidgetHTML = '';
function bhoSdkMain(){
(function(){
jumpQuery(document).ready(function($){
var css_link = $("", {
rel: "stylesheet",
type: "text/css",
href: bho_BASE_URL_lib +"widget/css/bho-sdk.css?v=3"
});
css_link.appendTo('head');
/* css_link = $("", {
rel: "stylesheet",
type: "text/css",
href: "//use.fontawesome.com/releases/v5.1.0/css/all.css"
});
css_link.appendTo('head'); */
function bho_setInitElements(jmpr_widget_type){
console.log(jmpr_widget_type);
if(document.getElementById("jumperInContextContainer")){
document.getElementById("jumperInContextContainer").classList.add("jumperWidgetContainer");
}
if(document.getElementById("jumperWidgetContainer")){
document.getElementById("jumperWidgetContainer").classList.add("jumperWidgetContainer");
}
if(jmpr_widget_type == 'incontext'){
var shopLink = $('#jumperInContextContainer').attr('data-jmpr_shoplink');
var shopName = $('#jumperInContextContainer').attr('data-jmpr_shopname');
var shopLogo = $('#jumperInContextContainer').attr('data-jmpr_shoplogo');
var customBgColor = $('#jumperInContextContainer').attr('data-jmpr_bgcolor');
var serviceType = $('#jumperInContextContainer').attr('data-jmpr_servicetype');
var jmpr_shoppage_template = $('#jumperInContextContainer').attr('data-jmpr_shoppage_template');
var jmpr_autostart_chat = $('#jumperInContextContainer').attr('data-jmpr_autostart_chat');
var jmpr_dashboard_preview = $('#jumperInContextContainer').attr('data-jmpr_dashboard_preview');
}
else{
var shopLink = $('#jumperWidgetContainer').attr('data-jmpr_shoplink');
var shopName = $('#jumperWidgetContainer').attr('data-jmpr_shopname');
var shopLogo = $('#jumperWidgetContainer').attr('data-jmpr_shoplogo');
var customBgColor = $('#jumperWidgetContainer').attr('data-jmpr_bgcolor');
var serviceType = $('#jumperWidgetContainer').attr('data-jmpr_servicetype');
var jmpr_shoppage_template = $('#jumperWidgetContainer').attr('data-jmpr_shoppage_template');
var jmpr_dashboard_preview = $('#jumperWidgetContainer').attr('data-jmpr_dashboard_preview');
}
if(jmpr_shoppage_template == 'true'){
/* css_link = $("", {
rel: "stylesheet",
type: "text/css",
href: bho_BASE_URL_lib +"widget/css/bho-sdk-shop-template.css"
});
css_link.appendTo('head'); */
}
if(typeof customBgColor == 'undefined'){
customBgColor = "#3d39b9";
}
document.documentElement.style.setProperty('--main-bg-color', customBgColor);
var customBgColorWithoutHash = customBgColor.replace("#", '');
if(shopLogo == '' || shopLogo == 'None' || shopLogo == null || typeof shopLogo == 'undefined'){
shopLogo = bho_BASE_URL +"web-b/resources/images/messaging-commerce-grey-with-padding.jpg";
}
if(serviceType == 'restaurant'){
//var bho_isVisible_icon_html = '';
var bho_isVisible_icon_html = '';
}
else{
var bho_isVisible_icon_html = '';
}
jumperWidgetHTML += '
\
'+ bho_isVisible_icon_html;
jumperWidgetHTML += '
\
\
\
\
\
\
\
\
\
'+ shopName +'
\
Instant checkout
\
\
\
Scroll through our top products\
\
and, if you like anything, just tap to buy!
\
\
\
';
var jumperWidgetMainPartHTML = '
\
';
if(jmpr_widget_type != 'incontext'){
jumperWidgetHTML += jumperWidgetMainPartHTML;
}
else{
jumperWidgetMainPartHTML += '
';
jumperWidgetMainPartHTML = '
\
'+ jumperWidgetMainPartHTML +'\
\
\
\
';
}
jumperWidgetHTML += '
\
';
setTimeout(function(){
if(jmpr_widget_type == 'incontext'){
$('#jumperInContextContainer').html(jumperWidgetMainPartHTML);
}
else{
$('#jumperWidgetContainer').html(jumperWidgetHTML);
}
}, 800);
setTimeout(function(){
var jmpr_widget_USERID = $.cookie('jmpr_widget_USERID');
var bho_navigatorUserAgent = navigator.userAgent.toLowerCase();
var bho_window_newTab;
function bho_isApple(){
return bho_navigatorUserAgent.match(/(ipod|iphone|ipad)/) && bho_navigatorUserAgent.match(/applewebkit/);
}
if(bho_isApple()){
$('#bho_widgetBody').addClass('bho_deviceIphone');
}
if(jmpr_shoppage_template == 'true'){
$('#jumperInContextContainer').addClass('jmpr_shoppage_template');
}
if(jmpr_dashboard_preview == 'true'){
$('#jumperInContextContainer').addClass('jmpr_dashboard_preview');
}
function bho_widgetOpenToggle(type){
if(type == 'open'){
if(document.getElementById("bho_widgetBody")){
document.getElementById("bho_widgetBody").classList.add("bho_active");
}
if(document.getElementById("bho_widgetBodyMainChatArea")){
document.getElementById("bho_widgetBodyMainArea").classList.add("bho_bodyActive");
}
//$('.bho_widgetOpenerFloatingButton .fa-shopping-cart').removeClass('bho_isVisible').addClass('bho_isHidden');
//$('.bho_widgetOpenerFloatingButton img').removeClass('bho_isVisible').addClass('bho_isHidden');
//$('.bho_widgetOpenerFloatingButton .fa-times').removeClass('bho_isHidden').addClass('bho_isVisible');
}
else{
$('#bho_widgetBody').toggleClass('bho_active');
$('#bho_widgetBodyMainArea').toggleClass('bho_bodyActive');
if($('.bho_widgetOpenerFloatingButton .fa-times').hasClass('bho_isHidden')){
$('.bho_widgetOpenerFloatingButton .fa-shopping-cart').removeClass('bho_isVisible').addClass('bho_isHidden');
$('.bho_widgetOpenerFloatingButton img').removeClass('bho_isVisible').addClass('bho_isHidden');
$('.bho_widgetOpenerFloatingButton .fa-times').removeClass('bho_isHidden').addClass('bho_isVisible');
}
else{
$('.bho_widgetOpenerFloatingButton .fa-shopping-cart').removeClass('bho_isHidden').addClass('bho_isVisible');
$('.bho_widgetOpenerFloatingButton img').removeClass('bho_isHidden').addClass('bho_isVisible');
$('.bho_widgetOpenerFloatingButton .fa-times').removeClass('bho_isVisible').addClass('bho_isHidden');
}
}
}
$(document).on('click','.bho_widgetOpenerFloatingButton', function(){
bho_widgetOpenToggle();
});
$(document).on('click', '#chatHamburgerDropdown', function(){
$('.bho_widgetHamburgarMenuUl').toggleClass('bho_activeMenu');
});
$(document).on('click', 'li.bho_subMenuOpener', function(){
$('.bho_subMenuOpener').toggleClass('bho_subMenuActive');
});
$(document).on('click', '#bho_widgetHamburgarMenuUl li.actionLi', function(){
$('.bho_widgetHamburgarMenuUl').removeClass('bho_activeMenu');
$('.bho_subMenuOpener').removeClass('bho_subMenuActive');
var type = $(this).attr('data-type');
var title = $(this).attr('data-title');
var payload = $(this).attr('data-payload');
var url = $(this).attr('data-url');
if(type == "postback"){
bho_sendMyMessage(title, payload, 'none');
}
else{
window.open(url, "_blank");
}
});
/* $(document).on('click', 'body', function(e){
if($("#chatHamburgerDropdown").prop('checked') == true){
$('#chatHamburgerDropdown').prop('checked', false);
$('#bho_widgetHamburgarMenuUl').removeClass('bho_activeMenu');
}
else{
if(e.target.id == "bho_widgetHamburgarOpener" || e.target.id == "chatHamburgerDropdown"){
$('#chatHamburgerDropdown').prop('checked', true);
$('#bho_widgetHamburgarMenuUl').addClass('bho_activeMenu');
}
}
}); */
$('#bho_widgetBodyInnerScrollableArea').on('scroll', function(){
var currentScroll = $('#bho_widgetBodyInnerScrollableArea').scrollTop();
var topHeaderHeight = $('.bho_widgetBodyTop').height();
if(currentScroll >= 180){
if(document.getElementById("bho_widgetBody")){
document.getElementById("bho_widgetBody").classList.add("fixedTop");
}
}
});
$(document).on('keyup change click', '#bho_widgetChatInputText', function(){
if($("#bho_widgetChatInputText").val() != ''){
$('#bho_widgetChatSendButton').css('display','block');
}
else{
$('#bho_widgetChatSendButton').css('display','none');
}
});
$(document).on('submit','#bho_widgetChatForm', function(){
var bho_widgetChatInputText = $('#bho_widgetChatInputText').val().replace(/[<>{}|\~`]/g,'');
if(bho_widgetChatInputText != ''){
$('#bho_widgetChatInputText').val('');
bho_sendMyMessage(bho_widgetChatInputText, bho_widgetChatInputText, 'inputBar');
}
return false;
});
function bho_scrollDownToBottom(){
var element = document.getElementById("bho_widgetBodyInnerScrollableArea");
element.scrollTop = element.scrollHeight;
if($(window).width() <= 1199){
if(jmpr_widget_type == 'incontext' && jmpr_shoppage_template == 'true'){
window.scrollTo(0,document.body.scrollHeight);
}
if(jmpr_widget_type == 'incontext' && jmpr_dashboard_preview == 'true'){
window.scrollTo(0,document.body.scrollHeight);
}
}
if(jmpr_widget_type == 'incontext'){
/* var hlafHeightOfScreen = window.innerHeight;
hlafHeightOfScreen = hlafHeightOfScreen / 1.5;
$('html, body').animate({
scrollTop: $("#bho_widgetChatInputArea").offset().top - hlafHeightOfScreen
}, 1000); */
}
}
//new message audio start
var bho_audio = new Audio(bho_BASE_URL_lib +'web-s/resources/jmpr-new-message-notification.mp3');
bho_audio.preload = 'auto';
//new message audio end
function bho_sanitizeHtml(input){
if(typeof input != 'undefined'){
if(input == '' || input == null || input == 'None'){
return input;
}
else{
var words_arr = input.split(' ');
for(var i in words_arr){
var single_word = words_arr[i];
if(single_word.indexOf('=') > -1 && single_word.indexOf('http://') == -1 && single_word.indexOf('https://') == -1){
var fullstring = single_word.split('=');
var first_string = fullstring[0];
var leftOut_string = fullstring[1];
if(first_string != 'href' && first_string != 'src' && first_string != 'style' && first_string != 'target'){
words_arr[i] = first_string +"ext="+ leftOut_string;
}
}
}
var outputText = words_arr.join(' ');
if(outputText.indexOf('') > -1){
outputText = outputText.replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g, '/');
}
outputText = outputText.replace(/