1jQuery(function ($) { 2 /****************************** 3 Jarvis Chat bot 4 *********************************/ 5 //Global 6 var userHitNum = 0; 7 var confirmaNotName = 0; 8 var infiniteChat = 0; 9 var chatInitialize = 0; 10 var qcld_woow_boot_user_init_name = 0; 11 var wooChatBotVar = woo_chatbot_obj; 12 13 var globalwoow={ 14 initialize:0, 15 settings:woo_chatbot_obj, 16 wildCard:0, 17 wildcards:'', 18 bargainStep:'welcome', // bargin welcome message 19 bargainId:0, // bargin product id 20 bargainVId:0, // bargin product variation id 21 bargainPrice:0, // bargin price 22 bargainLoop:0, // bargin price 23 sendusemailemail: '', 24 sendusemailstep: 0, 25 sendusemailmsg: '', 26 27 }; 28 29 $(document).ready(function(){ 30 //console.log(wooChatBotVar.map_get_email_address); 31 //show it 32 $('#woo-chatbot-ball-wrapper').css({ 33 'display':'block', 34 }); 35 //WooChatBot icon position. 36 $('#woo-chatbot-icon-container').css({ 37 'right': wooChatBotVar.woo_chatbot_position_x + 'px', 38 'bottom': wooChatBotVar.woo_chatbot_position_y + 'px' 39 }) 40 //window resize. 41 var widowH=$(window).height(); 42 var widowW=$(window).width(); 43 if(widowH<=1200 && widowH>=700 ){ 44 var ballConH=parseInt(widowH*0.5); 45 $('.woo-chatbot-ball-inner').css({ 'height':ballConH+'px'}) 46 47 $(window).resize(function(){ 48 var widowH=$(window).height(); 49 var ballConH=parseInt(widowH*0.5); 50 $('.woo-chatbot-ball-inner').css({ 'height':ballConH+'px'}) 51 }); 52 } 53 //Woo chat bot show and initial message. 54 var botimage = jQuery('#woo-chatbot-ball').find('img').attr('src'); 55 $(document).on('click', '#woo-chatbot-ball', function (event) { 56 $("#woo-chatbot-ball-container").toggle(); 57 $('.woo-chatbot-ball-inner').slimScroll({height: '50hv',start : 'bottom'}); 58 localStorage.setItem("wildCard", 0); 59 60 if(widowW<=767) {//For mobile 61 $('.woo-chatbot-admin').show(); 62 var headerH = $('.woo-chatbot-admin').outerHeight(); 63 var footerH = $('.woo-chatbot-editor-container').outerHeight(); 64 //var AppContentInner = widowH - footerH - headerH; 65 //var AppContentInner = widowH + headerH; 66 var AppContentInner = widowH; 67 68 //alert(footerH); 69 $('.woo-chatbot-ball-inner').css({'height': (AppContentInner-105) + 'px'}) 70 if ($('#woo-chatbot-mobile-close').length <= 0) { 71 $('.woo-chatbot-admin').append('<div id="woo-chatbot-mobile-close">X</div>'); 72 } 73 $('#woo-chatbot-ball').hide(); 74 $('#woo-chatbot-icon-container').css({'bottom':'0','left':'0','right':'0'}); 75 $('.woo-chatbot-ball-container').css({'bottom':'0','left':'0'}); 76 } 77 78 var qcld_woow_boot_user_init_name = localStorage.getItem("qcld_woow_boot_user_init_name"); 79 80 // console.log(qcld_woow_boot_user_init_name); 81 82 //close button 83 if($('#woo-chatbot-ball-container').is(':visible')){ 84 85 $('#woo-chatbot-ball').removeClass('woobot_chatclose_iconanimation'); 86 $('#woo-chatbot-ball').addClass('woobot_chatopen_iconanimation'); 87 $('#woo-chatbot-ball').find('img').attr('src', wooChatBotVar.image_path+'woowbot-close-icon.png'); 88 89 }else{ 90 91 $('#woo-chatbot-ball').removeClass('woobot_chatopen_iconanimation'); 92 $('#woo-chatbot-ball').addClass('woobot_chatclose_iconanimation'); 93 $('#woo-chatbot-ball').find('img').attr('src', botimage) 94 $('.woo-chatbot-ball').css('background', '#ffffff'); 95 96 } 97 98 if($('#woo-chatbot-ball-container').is(':visible')){ 99 100 101 102 if(chatInitialize==0 && qcld_woow_boot_user_init_name == null){ 103 // Working only for bot not user. 104 disable_message_editor(); 105 106 //Initiliaze message 107 var botJoinMsg="<span class='woo-chatbot-agent-joint'><strong>"+wooChatBotVar.agent+" </strong> "+wooChatBotVar.agent_join+"</span>"; 108 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 109 110 setTimeout(function(){ 111 $("#woo-chatbot-messages-container li:last").css({'background-color': 'transparent','border':'none'}).html(get_avatar_client_img()+botJoinMsg); 112 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 113 var botInitialeMsg="<span>"+wooChatBotVar.welcome+" <strong>"+wooChatBotVar.host+"!</strong> "+wooChatBotVar.asking_name+"</span>"; 114 setTimeout(function(){ 115 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+botInitialeMsg); 116 //enable user work 117 enable_message_editor(); 118 }, 1500); 119 120 121 }, 1500); 122 chatInitialize++; 123 }else{ 124 125 var wooChatBotMsg =wooChatBotVar.i_am +" <strong>"+wooChatBotVar.agent+"</strong>! "+wooChatBotVar.name_greeting+", <strong>"+qcld_woow_boot_user_init_name+"</strong>!"; 126 127 //Asking for typing a product! 128 if($("#woo-chatbot-messages-container li").length==0){ 129 setTimeout(function(){ 130 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 131 //Afer 1.5 second show product asking. 132 setTimeout(function(){ 133 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotMsg+"<span>"); 134 //scroll at the last message. 135 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 136 137 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 138 139 setTimeout(function(){ 140 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotVar.product_asking+"<span>"); 141 //scroll at the last message. 142 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 143 144 }, 1500); 145 146 //enable user work 147 enable_message_editor(); 148 149 }, 1500); 150 }, 1000); 151 } 152 153 154 155 } 156 } 157 158 }); 159 $(document).on('click', '#woo-chatbot-mobile-close', function (event) { 160 $("#woo-chatbot-ball-container").toggle(); 161 $('#woo-chatbot-icon-container').css({ 162 'right': '30px', 163 'bottom': '30px'}); 164 $('#woo-chatbot-ball').show(); 165 166 //close button 167 $('#woo-chatbot-ball').removeClass('woobot_chatopen_iconanimation'); 168 $('#woo-chatbot-ball').addClass('woobot_chatclose_iconanimation'); 169 $('#woo-chatbot-ball').find('img').attr('src', botimage) 170 $('.woo-chatbot-ball').css('background', '#ffffff'); 171 172 173 }); 174 //Hide Woo chat bot box if click on outside of icon. 175 // $(document).on('click',function (e) { 176 // var container = $("#woo-chatbot-ball-container"); 177 // var rejectContainer = $("#woo-chatbot-ball"); 178 // var bargainContainer = $(".woo_minimum_accept_price-bargin"); 179 // if(!rejectContainer.is(e.target) && rejectContainer.has(e.target).length === 0){ 180 // if (!bargainContainer.is(e.target) && bargainContainer.has(e.target).length === 0) { 181 // if (!container.is(e.target) && container.has(e.target).length === 0) { 182 // container.fadeOut(500); 183 // } 184 // } 185 // } 186 // }); 187 //For send button click 188 $(document).on('click',"#woo-chatbot-send-message",function(){ 189 190 var wildCardCheck = localStorage.getItem("wildCard"); 191 192 var qcld_woow_boot_user_init_name = localStorage.getItem("qcld_woow_boot_user_init_name"); 193 194 if( userHitNum == 10 ){ 195 user_action(); 196 }else if(wildCardCheck == 9){ 197 userHitNum = 9 ; 198 user_action(); 199 // console.log('bargain'); 200 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 201 }else if(qcld_woow_boot_user_init_name != null){ 202 203 userHitNum = 2; 204 user_action(); 205 206 }else{ 207 userHitNum++; 208 user_action(); 209 // console.log('bargain not'); 210 } 211 212 // userHitNum++; 213 // user_action(); 214 }) 215 //For keyboard enter. 216 $("#woo-chatbot-editor").on('keypress',function(event) { 217 var wildCardCheck = localStorage.getItem("wildCard"); 218 219 var qcld_woow_boot_user_init_name = localStorage.getItem("qcld_woow_boot_user_init_name"); 220 console.log(userHitNum); 221 if (event.which == 13) { 222 event.preventDefault(); 223 if( userHitNum == 10 ){ 224 user_action(); 225 }else if(wildCardCheck == 9){ 226 userHitNum = 9 ; 227 user_action(); 228 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 229 // console.log('bargain'); 230 }else if(qcld_woow_boot_user_init_name != null){ 231 userHitNum = 2; 232 user_action(); 233 }else{ 234 userHitNum++; 235 user_action(); 236 } 237 238 239 } 240 }); 241 242 }); 243 244 245 /******* Bot and user interaction start here***************/ 246 function htmlTagsScape(userString) { 247 var tagsToReplace = { 248 '&': '&', 249 '<': '<', 250 '>': '>' 251 }; 252 return userString.replace(/[&<>]/g, function(tag) { 253 return tagsToReplace[tag] || tag; 254 }); 255 } 256 function user_action(){ 257 var d = document; 258 var userText =$.trim( $("#woo-chatbot-editor").val()); 259 if(userText != ""){ 260 userText=htmlTagsScape(userText); 261 $("#woo-chatbot-messages-container").append("<li class='woo-chat-user-msg'>"+get_avatar_user_img()+"<span class='woo-chatbot-paragraph'>"+userText+"<span></li>"); 262 263 //scroll at the last message. 264 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 265 bot_action(userText); 266 $("#woo-chatbot-editor").val(""); 267 } 268 } 269 270 function get_avatar_user_img(){ 271 return '<div class="woo-chatbot-avatar"><img src="'+wooChatBotVar.agent_image_path+'" alt=""></div>'; 272 } 273 function get_avatar_client_img(){ 274 return '<div class="woo-chatbot-avatar"><img src="'+wooChatBotVar.agent_image_path+'" alt=""></div>'; 275 } 276 277 function bot_action(userText) { 278 //Disable the input and button when bot will start working.. 279 disable_message_editor(); 280 if(userHitNum != 9 ){ 281 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 282 } 283 284 infiniteChat=userText 285 //Greeting and Name asking part. 286 if(userHitNum ==1 && infiniteChat!=1){ 287 //Checking some common answer excpet name. 288 var notName=["sure", "yes","yea", "yeah","no","nope","certainly","never"]; 289 if(notName.indexOf(userText)>-1 && confirmaNotName==0 ){ 290 var wooChatBotMsg = "<strong>"+userText+"</strong> is your name?"; 291 userHitNum--; 292 confirmaNotName++; 293 //Asking Name again! 294 setTimeout(function(){ 295 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 296 //Afer 1.5 second show asking again. 297 setTimeout(function(){ 298 // $("#woo-chatbot-messages-container li:last").html("<span>Would you please confirm your name?<span>"); 299 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>Would you please confirm your name?<span>"); 300 //scroll at the last message. 301 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 302 //enable user work 303 enable_message_editor(); 304 305 }, 1500); 306 }, 2000); 307 308 }else{ 309 310 311 localStorage.setItem("qcld_woow_boot_user_init_name", userText); 312 313 314 var wooChatBotMsg =wooChatBotVar.i_am +" <strong>"+wooChatBotVar.agent+"</strong>! "+wooChatBotVar.name_greeting+", <strong>"+userText+"</strong>!"; 315 316 //Asking for typing a product! 317 setTimeout(function(){ 318 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 319 //Afer 1.5 second show product asking. 320 setTimeout(function(){ 321 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotVar.product_asking+"<span>"); 322 //scroll at the last message. 323 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 324 //enable user work 325 enable_message_editor(); 326 327 }, 1500); 328 }, 2000); 329 } 330 setTimeout(function(){ 331 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotMsg+"<span>"); 332 //scroll at the last message. 333 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 334 335 }, 1500); 336 } 337 //For infinite asking answering 338 if(userHitNum ==1 && infiniteChat==1){ 339 console.log( 'hello' ); 340 setTimeout(function(){ 341 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+'<span>'+wooChatBotVar.product_infinite+'<span>'); 342 //scroll at the last message. 343 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 344 //enable user work 345 enable_message_editor(); 346 347 }, 2500); 348 } 349 350 //Product handling steps. 351 if(userHitNum ==2){ 352 //Searching product using given user strings. 353 var data = { 354 'action':'qcld_woo_chatbot_keyword', 355 'keyword':userText, 356 }; 357 $.post(wooChatBotVar.ajax_url, data, function (response) { 358 // console.log(response); 359 if(r
359esponse.product_num==0){ 360 var wooChatBotMsg = wooChatBotVar.product_fail+" <strong>"+userText+"</strong>!"; 361 //suggesting product by category. 362 setTimeout(function(){ 363 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 364 //Afer 1.5 second show suggesting. 365 setTimeout(function(){ 366 367 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+ wooChatBotVar.specific_fail +"<span>"); 368 369 var html = '<span class="woobot_product_search qcld-chatbot-button" type="button" >'+ wooChatBotVar.product_search +'</span>'; 370 html += '<span class="woobot_catalog qcld-chatbot-button" type="button" >'+ wooChatBotVar.catalog +'</span>'; 371 html += '<span class="woobot_send_us_email qcld-chatbot-button" type="button" >'+ wooChatBotVar.send_us_email +'</span>'; 372 373 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 374 375 $("#woo-chatbot-messages-container li:last").css({'background-color': 'transparent','border':'none'}).html("<div>"+html +"</div>"); 376 377 //scroll at the last message. 378 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 379 enable_message_editor() 380 }, 1500); 381 }, 2000); 382 383 384 }else{ 385 var wooChatBotMsg = wooChatBotVar.product_success+" <strong>"+userText+"</strong>!"; 386 //Showing product from ajax response 387 setTimeout(function(){ 388 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 389 setTimeout(function(){ 390 //Afer 1.5 second show categories. 391 $("#woo-chatbot-messages-container li:last").css({'background-color': 'transparent','border':'none','width':'100%'}).html(response.html); 392 //scroll at the last message. 393 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 394 enable_message_editor() 395 }, 1500); 396 397 }, 2500); 398 //Setting infinite value as 399 setTimeout(function(){ 400 $("#woo-chatbot-send-message").prop("disabled", true); 401 userHitNum=1; 402 bot_action(1); 403 }, 6000); 404 } 405 setTimeout(function(){ 406 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotMsg+"<span>"); 407 //scroll at the last message. 408 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 409 //enable user work 410 //enable_message_editor(); 411 412 }, 1500); 413 }); 414 } 415 //category handling steps. 416 if(userHitNum ==3){ 417 var userTexts=userText.split("#"); 418 var categoryTitle=userTexts[0]; 419 var categoryId=userTexts[1]; 420 //Getting product by clicked category. 421 var data = { 422 'action':'qcld_woo_chatbot_category_products', 423 'category':categoryId, 424 }; 425 $.post(wooChatBotVar.ajax_url, data, function (response) { 426 if(response.product_num==0){ 427 var wooChatBotMsg = wooChatBotVar.product_fail+" <strong>"+categoryTitle+"</strong>!"; 428 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotMsg+"</span>"); 429 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 430 //scroll at the last message. 431 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 432 //suggesting product by category. 433 setTimeout(function(){ 434 //Afer 1.5 second show suggesting. 435 setTimeout(function(){ 436 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotVar.product_infinite+"<span>"); 437 //scroll at the last message. 438 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 439 //enable user work 440 enable_message_editor(); 441 442 }, 1500); 443 }, 2000); 444 445 } else{ 446 //Now show chat message to choose the product. 447 var wooChatBotMsg = wooChatBotVar.product_success+" <strong>"+categoryTitle+"</strong>!"; 448 //Showing Chat boat message with product. 449 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotMsg+"<span>"); 450 //scroll at the last message. 451 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 452 453 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 454 setTimeout(function(){ 455 $("#woo-chatbot-messages-container li:last").css({'background-color': 'transparent','border':'none','width':'100%'}).html(response.html); 456 //scroll at the last message. 457 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 458 459 460 }, 1500);
461 //Setting infinite value as 462 setTimeout(function(){ 463 userHitNum=1; 464 bot_action(1); 465 }, 5500); 466 467 } 468 469 470 }); 471 472 } 473 474 if( userHitNum == 5 ){ 475 //Getting the category by ajax to show at the bottom of chat box. 476 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotVar.product_suggest+"<span>"); 477 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 478 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 479 var cat_data = { 480 'action':'qcld_woo_chatbot_category', 481 }; 482 $.post(wooChatBotVar.ajax_url, cat_data, function (cat_response) { 483 // $("#bot-bottom").html(cat_response); 484 setTimeout(function(){ 485 $("#woo-chatbot-messages-container li:last").css({'background-color': 'transparent','border':'none'}).html("<div>"+cat_response +"</div>"); 486 //scroll at the last message. 487 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 488 enable_message_editor(); 489 }, 1500); 490 491 }); 492 } 493 494 //handling send us email 495 if( userHitNum == 10 ){ 496 497 if( globalwoow.sendusemailstep == 0 ){ 498 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotVar.provide_email_address+"<span>"); 499 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 500 enable_message_editor(); 501 globalwoow.sendusemailstep = 1; 502 }else if( globalwoow.sendusemailstep == 1 && globalwoow.sendusemailemail == '' && userText != '' ){ 503 globalwoow.sendusemailemail = userText; 504 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotVar.chatbot_write_your_message+"<span>"); 505 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 506 enable_message_editor(); 507 globalwoow.sendusemailstep = 2; 508 }else if( globalwoow.sendusemailstep == 2 && globalwoow.sendusemailstep != '' && userText != '' ){ 509 globalwoow.sendusemailmsg = userText; 510 511 var data = { 512 'action':'qcld_woo_chatbot_email', 513 'name': localStorage.getItem("qcld_woow_boot_user_init_name"), 514 'page': window.location.href, 515 'email': globalwoow.sendusemailemail, 516 'message': globalwoow.sendusemailmsg 517 }; 518 $.post(wooChatBotVar.ajax_url, data, function (response) { 519 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotVar.email_successfully+"<span>"); 520 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 521 enable_message_editor(); 522 userHitNum = 2; 523 }) 524 525 } 526 527 528 } 529 530 //bargain product 531 if(userHitNum == 9 ){ 532 533 534 if(globalwoow.wildCard==9 && globalwoow.bargainStep == 'welcome' && globalwoow.bargainId != ''){ 535 536 //alert(userText); 537 var data = { 538 'action':'qcld_woo_bargin_product', 539 'qcld_woo_map_product_id':globalwoow.bargainId, 540 'qcld_woo_map_variation_id':globalwoow.bargainVId, 541 'security': wooChatBotVar.map_free_get_ajax_nonce 542 543 }; 544 //woowKits.ajax(data).done(function (response) { 545 $.post(wooChatBotVar.ajax_url, data, function (response) { 546 var restWarning = response.html; 547 var confirmBtn = wooChatBotVar.your_offer_price; 548 549 var timerCount = 2500; 550 551 if($('.woo-chatbot-msg').length > 3){ 552 timerCount = 100; 553 } 554 555 setTimeout(function(){ 556 557 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 558 559 setTimeout(function(){ 560 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+restWarning); 561 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 562 563 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 564 565 566 567 if( ($.cookie('qcld_map_product_v_previous_id_'+globalwoow.bargainId) == globalwoow.bargainId) && ($.cookie('qcld_map_product_v_previous_variable_id_'+globalwoow.bargainVId) == globalwoow.bargainVId) ) { 568 569 setTimeout(function(){ 570
571 globalwoow.bargainStep = 'bargain'; 572 573 globalwoow.bargainId = $.cookie('qcld_map_product_v_previous_id_'+globalwoow.bargainId) ? $.cookie('qcld_map_product_v_previous_id_'+globalwoow.bargainId) : ''; 574 globalwoow.bargainVId = $.cookie('qcld_map_product_v_previous_variable_id_'+globalwoow.bargainVId) ? $.cookie('qcld_map_product_v_previous_variable_id_'+globalwoow.bargainVId) : ''; 575 globalwoow.bargainPrice = $.cookie('qcld_map_product_v_previous_price_'+globalwoow.bargainVId) ? $.cookie('qcld_map_product_v_previous_price_'+globalwoow.bargainVId) : 0; 576 577 578 localStorage.setItem("bargainId", globalwoow.bargainId); 579 localStorage.setItem("bargainVId", globalwoow.bargainVId); 580 localStorage.setItem("bargainStep", globalwoow.bargainStep); 581 localStorage.setItem("bargainPrice", globalwoow.bargainPrice); 582 583 var confirmBtn = wooChatBotVar.map_acceptable_prev_price.replace("{offer price}", parseFloat(globalwoow.bargainPrice) + globalwoow.settings.currency_symbol); 584 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn + '<span>'); 585 586 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 587 var confirmBtn = '<span class="qcld-modal-bargin-confirm-add-to-cart" confirm-data="yes" >Yes</span> <span> Or </span><span class="qcld-chatbot-bargin-confirm-btn" confirm-data="no"> No </span>'; 588 589 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn + '<span>'); 590 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 591 }, 1800); 592 593 }else if( $.cookie('qcld_map_product_previous_id_'+globalwoow.bargainId) == globalwoow.bargainId ) { 594 595 setTimeout(function(){ 596 597 globalwoow.bargainStep = 'bargain'; 598 599 globalwoow.bargainId = $.cookie('qcld_map_product_previous_id_'+globalwoow.bargainId) ? $.cookie('qcld_map_product_previous_id_'+globalwoow.bargainId) : ''; 600 globalwoow.bargainPrice = $.cookie('qcld_map_product_previous_id_price_'+globalwoow.bargainId) ? $.cookie('qcld_map_product_previous_id_price_'+globalwoow.bargainId) : 0; 601 globalwoow.bargainVId = ''; 602 603 localStorage.setItem("bargainId", global
603woow.bargainId); 604 localStorage.setItem("bargainVId", globalwoow.bargainVId); 605 localStorage.setItem("bargainStep", globalwoow.bargainStep); 606 localStorage.setItem("bargainPrice", globalwoow.bargainPrice); 607 608 var confirmBtn = wooChatBotVar.map_acceptable_prev_price.replace("{offer price}", parseFloat(globalwoow.bargainPrice) + globalwoow.settings.currency_symbol); 609 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn + '<span>'); 610 611 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 612 var confirmBtn = '<span class="qcld-modal-bargin-confirm-add-to-cart" confirm-data="yes" >Yes</span> <span> Or </span><span class="qcld-chatbot-bargin-confirm-btn" confirm-data="no"> No </span>'; 613 614 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn + '<span>'); 615 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 616 }, 1800); 617 618 }else{ 619 620 setTimeout(function(){ 621 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn + '<span>'); 622 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 623 }, 1500); 624 625 } 626 627 }, 1000); 628 629 }, timerCount); 630 631 632 633 globalwoow.bargainStep = 'bargain'; 634 globalwoow.bargainLoop = 0; 635 globalwoow.bargainPrice = ''; 636 globalwoow.bargainId = globalwoow.bargainId; 637 globalwoow.bargainVId = globalwoow.bargainVId; 638 localStorage.setItem("wildCard", localStorage.getItem("wildCard")); 639 localStorage.setItem("bargainLoop", globalwoow.bargainLoop); 640 localStorage.setItem("bargainPrice", globalwoow.bargainPrice);
641 localStorage.setItem("bargainId", globalwoow.bargainId); 642 localStorage.setItem("bargainVId", globalwoow.bargainVId); 643 644 enable_message_editor(); 645 646 }); 647 648 649 }else if(globalwoow.wildCard == 9 && globalwoow.bargainStep == 'bargain' && userText !== ""){ 650 651 // setTimeout(function(){ 652 var string = userText; 653 654 //var spliting = string.match(/\d+/g); 655 var spliting = string.match(/\d+(?:\.\d+)?/g); 656 657 if(spliting===null){ 658 // woowMsg.single(globalwoow.your_offer_price_again); 659 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+globalwoow.your_offer_price_again); 660 661 }else{ 662 663 664 // var msg = string.match(/\d+/g).map(Number); 665 var msg = string.match(/\d+(?:\.\d+)?/g).map(Number); 666 667 var data = { 668 'action':'qcld_woo_bargin_product_price', 669 'qcld_woo_map_product_id':globalwoow.bargainId, 670 'qcld_woo_map_variation_id':globalwoow.bargainVId, 671 'price': parseFloat(msg), 672 'security': wooChatBotVar.map_free_get_ajax_nonce 673 }; 674 675 // woowKits.ajax(data).done(function (response) { 676 $.post(wooChatBotVar.ajax_url, data, function (response) { 677 678 globalwoow.bargainStep = 'bargain'; 679 globalwoow.bargainPrice = response.sale_price; 680 localStorage.setItem("bargainStep", globalwoow.bargainStep); 681 localStorage.setItem("bargainPrice", globalwoow.bargainPrice); 682 683 if(response.confirm == 'success'){ 684 // If user provide price below minimum price 685 if( globalwoow.bargainLoop == 1){ 686 var your_low_price_alert = globalwoow.settings.your_low_price_alert; 687 var confirmBtn1 = your_low_price_alert.replace("{offer price}", parseFloat(msg) + globalwoow.settings.currency_symbol); 688 var your_too_low_price_alert = globalwoow.settings.your_too_low_price_alert; 689 var restWarning = your_too_low_price_alert.replace("{minimum amount}", globalwoow.bargainPrice + globalwoow.settings.currency_symbol); 690 691 var confirmBtn='<span class="qcld-modal-bargin-confirm-add-to-cart" confirm-data="yes" >Yes</span> <span> Or </span><span class="qcld-chatbot-bargin-confirm-btn" confirm-data="no"> No </span>'; 692 // woowMsg.triple_nobg(confirmBtn1,restWarning,confirmBtn); 693 694 setTimeout(function(){ 695 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn1 + '</span>'); 696 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 697 698 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 699 700 setTimeout(function(){ 701 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + restWarning + '</span>'); 702 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 703 704 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 705 706 setTimeout(function(){ 707 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>
707' + confirmBtn + '</span>'); 708 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 709 }, 1500); 710 711 }, 1500); 712 713 714 715 }, 1500); 716 717 globalwoow.bargainLoop = 0; 718 localStorage.setItem("bargainLoop", globalwoow.bargainLoop); 719 720 enable_message_editor(); 721 722 }else{ 723 var restWarning= response.html; 724 725 setTimeout(function(){ 726 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + response.html + '</span>'); 727 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 728 }, 1500); 729 730 globalwoow.bargainLoop = 1; 731 localStorage.setItem("bargainLoop", globalwoow.bargainLoop); 732 enable_message_editor(); 733 } 734 735 736 }else if(response.confirm == 'agree'){ 737 // if user provide resonable price. 738 739 setTimeout(function(){ 740 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + response.html + '</span>'); 741 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 742 743 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 744 745 746 }, 1500); 747 748 setTimeout(function(){ 749 750 var data = { 751 'action':'qcld_woo_bargin_product_confirm', 752 'qcld_woo_map_product_id':globalwoow.bargainId, 753 'price': globalwoow.bargainPrice, 754 'security': wooChatBotVar.map_free_get_ajax_nonce 755 }; 756 757 $.post(wooChatBotVar.ajax_url, data, function (response) { 758 759 760 var confirmBtn='<span class="qcld-modal-bargin-confirm-add-to-cart" confirm-data="yes" > Yes </span> <span> OR </span><span class="qcld-chatbot-bargin-confirm-btn" confirm-data="no"> No </span>'; 761 762 763 setTimeout(function(){ 764 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + response.html + '</span>'); 765 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 766 767 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 768 769 770 setTimeout(function(){ 771 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn + '</span>'); 772 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 773 }, 1500); 774 775 }, 1500); 776 777
778 globalwoow.wildCard = 9; 779 globalwoow.bargainStep = 'bargain'; 780 globalwoow.bargainPrice = globalwoow.bargainPrice; 781 localStorage.setItem("wildCard", globalwoow.wildCard); 782 localStorage.setItem("bargainStep", globalwoow.bargainStep); 783 localStorage.setItem("bargainPrice", globalwoow.bargainPrice); 784 }); 785 786 },globalwoow.settings.preLoadingTime); 787 788 }else if(response.confirm == 'default'){ 789 790 var confirmBtn='<span class="qcld-chatbot-bargin-confirm-btn" confirm-data="back"> Back to Start </span>'; 791 792 setTimeout(function(){ 793 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + response.html + '</span>'); 794 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 795 796 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 797 798 799 setTimeout(function(){ 800 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn + '</span>'); 801 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 802 }, 1500); 803 804 805 }, 1500); 806 807 }else{ 808 809 setTimeout(function(){ 810 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + response.html + '</span>'); 811 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 812 }, 1500); 813 814 } 815 816 }); 817 } 818 // },globalwoow.settings.preLoadingTime); 819 820 }else if(globalwoow.wildCard==9 && globalwoow.bargainStep == 'confirm'){ 821 822 setTimeout(function(){ 823 824 var data = {'action':'qcld_woo_bargin_product_confirm', 825 'qcld_woo_map_product_id':globalwoow.bargainId, 826 'price': globalwoow.bargainPrice, 827 'security': wooChatBotVar.map_free_get_ajax_nonce 828 }; 829 $.post(wooChatBotVar.ajax_url, data, function (response) { 830 831 // map_acceptable_price 832 var restWarning = response.html; 833 var map_acceptable_price = globalwoow.settings.map_acceptable_price; 834 var confirmBtn1 = map_acceptable_price; 835 836 setTimeout(function(){ 837 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn1 + '</span>'); 838 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 839 840 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 841 842 setTimeout(function(){ 843 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + restWarning + '</span>'); 844 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 845 }, 1500); 846 847 }, 1500); 848 849
850 globalwoow.wildCard = 0; 851 globalwoow.bargainStep = 'welcome'; 852 globalwoow.bargainPrice = ''; 853 localStorage.setItem("wildCard", globalwoow.wildCard); 854 localStorage.setItem("bargainStep", globalwoow.bargainStep); 855 localStorage.setItem("bargainPrice", globalwoow.bargainPrice); 856 857 userHitNum = 1; 858 859 }); 860 861 },globalwoow.settings.preLoadingTime); 862 863 }else if(globalwoow.wildCard==9 && globalwoow.bargainStep == 'add_to_cart'){ 864 865 setTimeout(function(){ 866 867 if(globalwoow.bargainVId != ''){ 868 869 if ( $.cookie('qcld_map_product_v_previous_variable_id_'+globalwoow.bargainVId) != globalwoow.bargainVId ) { 870 871 $.cookie('qcld_map_product_v_previous_id_'+globalwoow.bargainId, globalwoow.bargainId); 872 $.cookie('qcld_map_product_v_previous_variable_id_'+globalwoow.bargainVId, globalwoow.bargainVId); 873 $.cookie('qcld_map_product_v_previous_price_'+globalwoow.bargainVId, globalwoow.bargainPrice); 874 875 } 876 877 var product_cookie = 'false'; 878 if( ($.cookie('qcld_map_product_v_previous_variable_id_'+globalwoow.bargainVId) == globalwoow.bargainVId) ) { 879 880 globalwoow.bargainId = $.cookie('qcld_map_product_v_previous_id_'+globalwoow.bargainId) ? $.cookie('qcld_map_product_v_previous_id_'+globalwoow.bargainId) : ''; 881 globalwoow.bargainVId = $.cookie('qcld_map_product_v_previous_variable_id_'+globalwoow.bargainVId) ? $.cookie('qcld_map_product_v_previous_variable_id_'+globalwoow.bargainVId) : ''; 882 globalwoow.bargainPrice = $.cookie('qcld_map_product_v_previous_price_'+globalwoow.bargainVId) ? $.cookie('qcld_map_product_v_previous_price_'+globalwoow.bargainVId) : 0; 883 884 localStorage.setItem("bargainId", global
884woow.bargainId); 885 localStorage.setItem("bargainVId", globalwoow.bargainVId); 886 localStorage.setItem("bargainPrice", globalwoow.bargainPrice); 887 var product_cookie = 'yes'; 888 } 889 890 var data = {'action':'qcld_woo_bargin_product_variation_add_to_cart', 891 'product_id':globalwoow.bargainId, 892 'variation_id':globalwoow.bargainVId, 893 'price': globalwoow.bargainPrice, 894 'product_cookie': product_cookie, 895 'security': wooChatBotVar.map_free_get_ajax_nonce 896 }; 897 898 }else{ 899 900 if ( $.cookie('qcld_map_product_previous_id_'+globalwoow.bargainId) != globalwoow.bargainId ) { 901 902 $.cookie('qcld_map_product_previous_id_'+globalwoow.bargainId, globalwoow.bargainId); 903 $.cookie('qcld_map_product_previous_id_price_'+globalwoow.bargainId, globalwoow.bargainPrice); 904 905 } 906 907 var product_cookie = 'false'; 908 if( $.cookie('qcld_map_product_previous_id_'+globalwoow.bargainId) == globalwoow.bargainId ) { 909 910 globalwoow.bargainId = $.cookie('qcld_map_product_previous_id_'+globalwoow.bargainId) ? $.cookie('qcld_map_product_previous_id_'+globalwoow.bargainId) : ''; 911 globalwoow.bargainPrice = $.cookie('qcld_map_product_previous_id_price_'+globalwoow.bargainId) ? $.cookie('qcld_map_product_previous_id_price_'+globalwoow.bargainId) : 0; 912 globalwoow.bargainVId = ''; 913 914 var product_cookie = 'yes'; 915 localStorage.setItem("bargainId", global
915woow.bargainId); 916 localStorage.setItem("bargainVId", globalwoow.bargainVId); 917 localStorage.setItem("bargainPrice", globalwoow.bargainPrice); 918 } 919 920 var data = { 921 'action':'qcld_woo_bargin_product_add_to_cart', 922 'product_id':globalwoow.bargainId, 923 'price': globalwoow.bargainPrice, 924 'product_cookie': product_cookie, 925 'security': wooChatBotVar.map_free_get_ajax_nonce 926 }; 927 } 928 929 930 // woowKits.ajax(data).done(function (response) { 931 $.post(wooChatBotVar.ajax_url, data, function (response) { 932 933 // map_acceptable_price 934 var restWarning = response.html; 935 936 var confirmBtn='<div class="woo-chatbot-product-bargain-btn"><a href="'+globalwoow.settings.map_get_checkout_url +'" class="qcld-modal-bargin-confirm-btn-checkout"> '+globalwoow.settings.map_checkout_now_button_text+' </a></div>'; 937 938 939 setTimeout(function(){ 940 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + restWarning + '</span>'); 941 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 942 943 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 944 945 setTimeout(function(){ 946 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn + '</span>'); 947 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 948 }, 1500); 949 950 }, 1500); 951 952 953 globalwoow.wildCard = 0; 954 globalwoow.bargainStep = 'welcome'; 955 globalwoow.bargainVId = ''; 956 globalwoow.bargainPrice = ''; 957 localStorage.setItem("wildCard", globalwoow.wildCard); 958 localStorage.setItem("bargainStep", globalwoow.bargainStep); 959 localStorage.setItem("bargainVId", global
959woow.bargainVId); 960 localStorage.setItem("bargainPrice", globalwoow.bargainPrice); 961 962 userHitNum = 1; 963 }); 964 965 },globalwoow.settings.preLoadingTime); 966 967 }else if(globalwoow.wildCard==9 && globalwoow.bargainStep == 'disagree' && globalwoow.bargainLoop == 0){ 968 969 // map_talk_to_boss msg 970 var map_talk_to_boss = globalwoow.settings.map_talk_to_boss; 971 var confirmBtn = map_talk_to_boss; 972 //woowMsg.single(confirmBtn); 973 setTimeout(function(){ 974 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn + '</span>'); 975 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 976 }, 1500); 977 978 globalwoow.bargainLoop = 1; 979 localStorage.setItem("bargainLoop", globalwoow.bargainLoop); 980 981 982 }else if(globalwoow.wildCard==9 && globalwoow.bargainStep == 'disagree' && globalwoow.bargainLoop == 1){ 983 984 var string = userText; 985 var spliting = string.match(/\d+/g); 986 987 if(spliting===null){ 988 // woowMsg.single(globalwoow.settings.your_offer_price_again); 989 setTimeout(function(){ 990 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + globalwoow.settings.your_offer_price_again + '</span>'); 991 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 992 }, 1500); 993 994 }else{ 995 // map_get_email_address 996 var map_get_email_address = globalwoow.settings.map_get_email_address; 997 var confirmBtn = map_get_email_address; 998 // woowMsg.single(confirmBtn); 999 setTimeout(function(){ 1000 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn + '</span>'); 1001 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 1002 }, 1500); 1003 1004 // var string = msg; 1005 // globalwoow.bargainPrice = userText.match(/\d+/g).map(Number); 1006 globalwoow.bargainPrice = userText.match(/\d+(?:\.\d+)?/g).map(Number); 1007 //globalwoow.bargainPrice = msg; 1008 //localStorage.setItem("wildCard", globalwoow.bargainPrice); 1009 localStorage.setItem("finalprice", globalwoow.bargainPrice); 1010 1011 1012 globalwoow.bargainLoop = 2; 1013 localStorage.setItem("bargainLoop", globalwoow.bargainLoop); 1014 } 1015 }else if(globalwoow.wildCard==9 && globalwoow.bargainStep == 'disagree' && globalwoow.bargainLoop == 2){ 1016 1017 // map_get_email_address 1018 var map_thanks_test = globalwoow.settings.map_thanks_test; 1019 var confirmBtn = map_thanks_test; 1020 1021 setTimeout(function(){ 1022 1023 //woowMsg.single(confirmBtn); 1024 setTimeout(function(){ 1025 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(get_avatar_client_img()+'<span>' + confirmBtn + '</span>'); 1026 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 1027 }, 1500); 1028 1029 var data = {'action':'qcld_woo_bargin_send_query', 1030 'qcld_woo_map_product_id':globalwoow.bargainId, 1031 'price': localStorage.getItem("finalprice"), 1032 'email': msg, 1033 'security': wooChatBotVar.map_free_get_ajax_nonce 1034 }; 1035 1036 $.post(wooChatBotVar.ajax_url, data, function (response) { 1037 //console.log(response); 1038 // woowMsg.single(confirmBtn); 1039 1040 }); 1041 1042 }
1042,globalwoow.settings.preLoadingTime); 1043 1044 globalwoow.bargainLoop = 0; 1045 localStorage.setItem("bargainLoop", globalwoow.bargainLoop); 1046 globalwoow.wildCard = 0; 1047 globalwoow.bargainStep = 'welcome'; 1048 globalwoow.bargainPrice = ''; 1049 localStorage.setItem("wildCard", globalwoow.wildCard); 1050 localStorage.setItem("bargainStep", globalwoow.bargainStep); 1051 localStorage.setItem("bargainPrice", globalwoow.bargainPrice); 1052 1053 userHitNum =1; 1054 1055 } 1056 1057 enable_message_editor(); 1058 1059 1060 } 1061 1062 1063 1064 } 1065 1066 1067 1068 1069 //When user click on the category then product will be show. 1070 $(document).on('click','.qcld-chatbot-product-category',function(){ 1071 userHitNum = 3; 1072 var nameCatID=$(this).text()+'#'+$(this).attr('data-category-id'); 1073 //Now hide the category and show the category for user. 1074 $("#woo-chatbot-messages-container .woo-chatbot-msg:last").fadeOut(1500); 1075 $("#woo-chatbot-messages-container").append("<li class='woo-chat-user-msg'><span>"+$(this).text()+"<span></li>"); 1076 //scroll at the last message. 1077 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 1078 1079 bot_action(nameCatID); 1080 }); 1081 1082 $(document).on('click','.woobot_product_search',function(){ 1083 userHitNum = 2; 1084 $("#woo-chatbot-messages-container").append("<li class='woo-chat-user-msg'>"+get_avatar_user_img()+"<span class='woo-chatbot-paragraph'>"+$(this).text()+"<span></li>"); 1085 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 1086 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 1087 setTimeout(function(){ 1088 $("#woo-chatbot-messages-container li:last").html(get_avatar_client_img()+"<span>"+wooChatBotVar.product_asking+"<span>"); 1089 //scroll at the last message. 1090 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 1091 1092 }, 1500); 1093 }); 1094 1095 $(document).on('click','.woobot_catalog',function(){ 1096 userHitNum = 5; 1097 $("#woo-chatbot-messages-container").append("<li class='woo-chat-user-msg'>"+get_avatar_user_img()+"<span class='woo-chatbot-paragraph'>"+$(this).text()+"<span></li>"); 1098 bot_action(); 1099 }); 1100 1101 $(document).on('click','.woobot_send_us_email',function(){ 1102 userHitNum = 10; 1103 globalwoow.sendusemailstep = 0; 1104 $("#woo-chatbot-messages-container").append("<li class='woo-chat-user-msg'>"+get_avatar_user_img()+"<span class='woo-chatbot-paragraph'>"+$(this).text()+"<span></li>"); 1105 bot_action(); 1106 }); 1107 1108 1109 function disable_message_editor(){ 1110 $("#woo-chatbot-editor").attr('placeholder',wooChatBotVar.agent+' '+wooChatBotVar.is_typing); 1111 $("#woo-chatbot-editor").attr('disabled',true); 1112 $("#woo-chatbot-send-message").attr('disabled',true); 1113 } 1114 function enable_message_editor(){ 1115 $("#woo-chatbot-editor").attr('disabled',false).focus(); 1116 $("#woo-chatbot-editor").attr('placeholder',wooChatBotVar.send_a_msg); 1117 $("#woo-chatbot-send-message").attr('disabled',false); 1118 } 1119 1120 // bargain ... 1121 1122 1123 //bargain initiate function 1124 $(document).on('click', '.woo_minimum_accept_price-bargin', function(e){ 1125 // alert('data id w'); 1126 var product_id = $(this).attr('product_id'); 1127 var variation_id = ''; 1128 1129 var variable_check = $('.woo_minimum_accept_price-bargin').parent().parent().find('.variation_id'); 1130 1131 if($( variable_check ).hasClass( "variation_id" )){ 1132 1133 var variation_id = $('.variation_id').val(); 1134 1135 if( variation_id == '0' || variation_id == '' ) { 1136 alert('Please select some product options before adding this product to your cart.'); 1137 return false;
1138 } 1139 1140 } 1141 1142 if($('#woo-chatbot-ball-container').css('display') == 'none'){ 1143 $('#woo-chatbot-ball').trigger('click'); 1144 } 1145 1146 userHitNum = 9; 1147 1148 globalwoow.wildCard = 9; 1149 globalwoow.bargainStep = 'welcome'; 1150 globalwoow.bargainId = product_id; 1151 globalwoow.bargainVId = variation_id; 1152 globalwoow.bargainPrice = ''; 1153 localStorage.setItem("wildCard", globalwoow.wildCard); 1154 localStorage.setItem("bargainStep", globalwoow.bargainStep); 1155 localStorage.setItem("bargainId", globalwoow.bargainId); 1156 localStorage.setItem("bargainPrice", globalwoow.bargainPrice); 1157 localStorage.setItem("bargainVId", globalwoow.bargainVId); 1158 1159 bot_action(); 1160 1161 $('.woo-chatbot-ball-inner').animate({ scrollTop: $('#woo-chatbot-messages-container').prop("scrollHeight")}, 'slow'); 1162 1163 }); 1164 1165 // bargain confirm ... 1166 $(document).on('click','.qcld-chatbot-bargin-confirm-btn',function (e) { 1167 e.preventDefault(); 1168 var shopperChoice=$(this).text(); 1169 //woowMsg.shopper_choice(shopperChoice); 1170 var actionType=$(this).attr('confirm-data'); 1171 1172 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(''); 1173 1174 $("#woo-chatbot-messages-container").append("<li class='woo-chat-user-msg'>"+get_avatar_user_img()+"<span>"+shopperChoice+"<span></li>"); 1175 1176 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 1177 1178 1179 if(actionType=='yes'){ 1180 1181 globalwoow.bargainStep = 'confirm'; 1182 localStorage.setItem("bargainStep", globalwoow.bargainStep); 1183 bot_action(); 1184 } else if(actionType=='no'){ 1185 globalwoow.bargainStep = 'disagree'; 1186 localStorage.setItem("bargainStep", globalwoow.bargainStep); 1187 globalwoow.bargainLoop = 0; 1188 localStorage.setItem("bargainLoop", globalwoow.bargainLoop); 1189 bot_action(); 1190 }else{ 1191 1192 localStorage.setItem("wildCard", 0); 1193 localStorage.setItem("bargainStep", 'welcome'); 1194 localStorage.setItem("bargainId", ''); 1195 userHitNum=1; 1196 bot_action(1); 1197 } 1198 }); 1199 $(document).on('click','.qcld-modal-bargin-confirm-add-to-cart',function (e) { 1200 e.preventDefault(); 1201 var shopperChoice=$(this).text(); 1202 //woowMsg.shopper_choice(shopperChoice); 1203 $("#woo-chatbot-messages-container li.woo-chatbot-msg:last").html(''); 1204 $("#woo-chatbot-messages-container").append("<li class='woo-chat-user-msg'>"+get_avatar_user_img()+"<span>"+shopperChoice+"<span></li>"); 1205 1206 $("#woo-chatbot-messages-container").append('<li class="woo-chatbot-msg"><img class="woo-chatbot-comment-loader" src="'+wooChatBotVar.image_path+'comment.gif" alt="Typing..." /></li>'); 1207 1208 1209 globalwoow.bargainId = localStorage.getItem('bargainId'); 1210 globalwoow.bargainVId = localStorage.getItem('bargainVId'); 1211 globalwoow.bargainPrice = localStorage.getItem('bargainPrice'); 1212 1213 globalwoow.bargainStep = 'add_to_cart'; 1214 localStorage.setItem("bargainStep", globalwoow.bargainStep); 1215 bot_action(); 1216 }); 1217 1218 1219 1220 1221 1222 1223});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.