1jQuery(document).ready(function($) { 2 document.addEventListener("keydown", function(event) { 3 if (event.key === "Enter" && event.target.tagName !== "TEXTAREA") { 4 event.preventDefault(); 5 } 6 }); 7 function summaryDates() { 8 const now = new Date(); 9 10 const optionsFull = { month: 'long', year: 'numeric' }; 11 const optionsShort = { month: 'short', year: 'numeric' }; 12 13 const current = now.toLocaleDateString('en-US', optionsShort); 14 15 const futureDate = new Date(); 16 futureDate.setMonth(futureDate.getMonth() + 2); 17 18 const by = '<span>by</span> ' + futureDate.toLocaleDateString('en-US', optionsFull); 19 const final = futureDate.toLocaleDateString('en-US', optionsShort); 20 21 return { 22 by: by, 23 current: current, 24 final: final 25 }; 26 } 27 28 29 function summaryCurrentBmi(summaryInfo) { 30 const weightLabels = [ 31 { 32 label: 'Underweight', 33 img: 'till-17.png', 34 'img-summary': 'till-17-2.png', 35 'img-mobile': 'till-17-2-mobile.png', 36 from: 0, 37 to: 18 38 }, 39 { 40 label: 'Healthy', 41 img: '18-24.png', 42 'img-summary': '18-24-2.png', 43 'img-mobile': '18-24-2-mobile.png', 44 from: 18, 45 to: 25 46 }, 47 { 48 label: 'Obese', 49 img: '25-27.png', 50 'img-summary': '25-27-2.png', 51 'img-mobile': '25-27-2-mobile.png', 52 from: 25, 53 to: 28 54 }, 55 { 56 label: 'Obese', 57 img: 'above-28.png', 58 'img-summary': 'above-28.png', 59 'img-mobile': 'above-28.png', 60 from: 28, 61 to: 100 62 } 63 ]; 64 65 let bmi = 0; 66 let weight = parseFloat(summaryInfo.weight); 67 let height = parseFloat(summaryInfo.height); 68 let measurments = summaryInfo.measurments; 69 70 if (measurments === 'imperial') { 71 height = parseFloat(summaryInfo.heightInches); 72 bmi = (weight / (height * height)) * 703; 73 } else { 74 height = height * 0.01; 75 bmi = weight / (height * height); 76 } 77 78 bmi = parseFloat(bmi.toFixed(2)); 79 80 let bmiLabel = null;
81 weightLabels.forEach(function (label) { 82 if (bmi >= label.from && bmi < label.to) { 83 bmiLabel = label; 84 } 85 }); 86 87 return { 88 bmi: bmi, 89 bmiLabel: bmiLabel 90 }; 91 } 92 93 let currentWeight = jQuery('.current-weight'); 94 if(currentWeight){ 95 $('input[name="weight"]').on('input', function() { 96 const weightValue = $(this).val(); // Get the value of the input 97 const weightType = $(this).parent().find('.change-txt-c').text();// Get the value of the input 98 $('.current-weight p').text('Now: ' + weightValue + weightType ); // Set the value to the inner text of the <p> element 99 }); 100 101 $('input[name="desired_weight"]').on('input', function() { 102 const desired_Weight = $(this).val(); // Get the value of the input 103 const desired_weightType = $(this).parent().find('.change-txt-c').text();// Get the value of the input 104 $('.desired-weight p').text('Goal: ' + desired_Weight + desired_weightType ); // Set the value to the inner text of the <p> element 105 }); 106 } 107 108 var active = $('.question-active'); 109 var custom_url = active.attr('data-custom-url'); 110 window.history.pushState("", "", '?q=' + custom_url); 111 if (typeof gtag == 'function') { 112 gtag('config', 'UA-200520999-1', {'page_path': '?q=' + custom_url}); 113 } else { 114 console.log('nogtag'); 115 } 116 $('.cta-button-disabled').click(function(e){ 117 e.preventDefault(); 118 }); 119
120 $('.back-quiz').click(function(e){ 121 e.preventDefault(); 122 move_to_previous_question(); 123 }); 124 125 function isEmail(email) { 126 var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; 127 return regex.test(email); 128 } 129 130 $('.cta-button').on('click', function(e){ 131 e.preventDefault(); 132 if($(this).hasClass('measurments-cta')) { 133 var valid = validateMeasurmentsForm(); 134 if(valid == 0) { 135 return; 136 } 137 } 138 if($(this).hasClass('measurments-cta-step')) { 139 var valid = validateMeasurmentsFormStep($(this)); 140 if(valid == 0) { 141 return; 142 } 143 } 144 // if($(this).hasClass('end-date-step')) { 145 // move_to_next_question(); 146 // } 147 148 if(!$(this).hasClass('cta-button-disabled') && $('.question-active').attr('data-question-id') != $('#quiz').attr('data-total')) { 149 move_to_next_question(); 150 } 151 }); 152 153 function validateMeasurmentsForm(){ 154 $('.error-messages-measurments').hide(); 155 var error_messages = ''; 156 // get value of kg or lb 157 var type = $('.imperial-metric input:checked').parent().attr('data-lb'); 158 159 if(type == 'lb') { 160 $('.minmax-height-kg').removeClass('minmax-height req-imp'); 161 $('.minmax-height-lb').addClass('minmax-height req-imp'); 162 } else { 163 $('.minmax-height-kg').addClass('minmax-height req-imp'); 164 $('.minmax-height-lb').removeClass('minmax-height req-imp'); 165 } 166 167 168 var valid = 1; 169 $('.req-imp').each(function(){ 170 if($(this).val() == '') { 171 $(this).addClass('invalid-inp'); 172 valid = 0; 173 } else { 174 $(this).removeClass('invalid-inp'); 175 } 176 }); 177 178 // validate age 179 var age = $('.minmax-age'), 180 age_val = parseInt(age.val()), 181 min_age = 18, 182 max_age = 100; 183 if(age_val < min_age || age_val > max_age) { 184 age.addClass('invalid-inp'); 185 error_messages += 'Please enter a valid age.<br />'; 186 valid = 0; 187 } 188 189 // validate height 190 if(type == 'lb') { 191 var height = $('.lb-inps .minmax-height'), 192 height_val = parseInt(height.val()), 193 min_height = 4, 194 max_height = 8; 195 } else { 196 var height = $('.inp-kg .minmax-height'), 197 height_val = parseInt(height.val()), 198 min_height = 120, 199 max_height = 245; 200 } 201 202 if(height_val < min_height || height_val > max_height) { 203 height.addClass('invalid-inp'); 204 error_messages += 'Please enter a valid height.<br />'; 205 valid = 0; 206 } 207 208 var inch = $('.validate-inch'), 209 inchval = inch.val(); 210 if(inchval > 11 || inchval < 0) { 211 inch.addClass('invalid-inp'); 212 } else { 213 inch.removeClass('invalid-inp'); 214 } 215 216 // weight 217 $('.minmax-weight').each(function(){ 218 var weight = $(this), 219 weight_val = parseInt(weight.val()); 220 if(type == 'lb') { 221 var min_weight = 80, 222 max_weight = 700; 223 } else { 224 var min_weight = 35, 225 max_weight = 315; 226 } 227 228 if(weight_val < min_weight || weight_val > max_weight) { 229 weight.addClass('invalid-inp'); 230 error_messages += 'Please enter a valid weight.<br />'; 231 valid = 0; 232 } 233 }); 234 235 var lessthan = $('.lessthan'), 236 morethan = $('.morethan'), 237 lessthanval = parseInt(lessthan.val()), 238 morethanval = parseInt(morethan.val()); 239 if(lessthanval > morethanval) { 240 error_messages += 'Please enter a valid target weight.<br />'; 241 valid = 0; 242 lessthan.addClass('invalid-inp'); 243 morethan.addClass('invalid-inp'); 244 } 245 246 if(error_messages) { 247 $('.error-messages-measurments div').html(error_messages); 248 $('.error-messages-measurments').show(); 249 } 250 return valid; 251 } 252 253 function validateMeasurmentsFormStep(step) { 254 var target = step.parent().parent();
255 var valid = 1; 256 257 // validate age 258 var age = $(target).find('input[name=age]'), 259 age_val = parseInt(age.val()) || 0, 260 min_age = 18, 261 max_age = 100; 262 if (age.length) { 263 if (age_val < min_age || age_val > max_age) { 264 age.addClass('invalid-inp'); 265 valid = 0; 266 }else{ 267 age.removeClass('invalid-inp'); 268 } 269 return valid; 270 } 271 272 var type = target.find('input.measurments-item:checked').parent().attr('data-lb'); 273 if (type == 'lb') { 274 $('.minmax-height-kg').removeClass('minmax-height req-imp'); 275 target.find('minmax-height-lb').addClass('minmax-height req-imp'); 276 var heightType = 'height_ft'; 277 var height = $('.lb-inps .minmax-height'), 278 height_val = parseInt(height.val()) || 0, 279 min_height = 4, 280 max_height = 8; 281 282 var min_weight = 80, 283 max_weight = 700; 284 285 } else { 286 target.find('minmax-height-kg').addClass('minmax-height req-imp'); 287 $('.minmax-height-lb').removeClass('minmax-height req-imp'); 288 var heightType = 'height_cm'; 289 var height = $('.inp-kg .minmax-height'), 290 height_val = parseInt(height.val()) || 0, 291 min_height = 120, 292 max_height = 245; 293 294 var min_weight = 35, 295 max_weight = 315; 296 } 297 var heightInput = $(target).find('input[name=' + heightType + ']'); 298 // validate height 299 if (heightInput.length) { 300 if (height_val < min_height || height_val > max_height) { 301 height.addClass('invalid-inp'); 302 valid = 0; 303 }else{ 304 height.removeClass('invalid-inp'); 305 } 306 307 return valid; 308 } 309 310 311 // validate weight 312 var weightInput = $(target).find('input[name=weight]'); 313 if (weightInput.length) { 314 var weight = weightInput, 315 weight_val = parseInt(weight.val()) || 0; 316 317 if (weight_val < min_weight || weight_val > max_weight) { 318 weight.addClass('invalid-inp'); 319 valid = 0; 320 } 321 return valid; 322 } 323 324 //validate desired weight 325 var desiredWeightInput = $(target).find('input[name=desired_weight]'); 326 if (desiredWeightInput.length) { 327 var lessthan = desiredWeightInput, 328 morethan = $('input[name=weight]'), 329 lessthanval = parseInt(lessthan.val()) || 1000, // 100 330 morethanval = parseInt(morethan.val()) || 0; 331 332 if (lessthanval > morethanval) { 333 valid = 0; 334 lessthan.addClass('invalid-inp'); 335 morethan.addClass('invalid-inp'); 336 } 337 return valid; 338 } 339 340 var reqInputs = target.find('.req-imp'); 341 $(reqInputs).each(function (e) { 342 if ($(this).val() == '') { 343 $(this).addClass('invalid-inp'); 344 valid = 0; 345 } else { 346 $(this).removeClass('invalid-inp'); 347 } 348 }); 349 return valid; 350 } 351 352 function move_to_next_question(){ 353 var quiz_count = variables.quiz_count, 354 active_question = $('.question-active'), 355 active_question_id = parseInt(active_question.attr('data-question-id')), 356 next_question_id = active_question_id + 1, 357 next_question = $('.question[data-question-id=' + next_question_id + ']'); 358 359 if(next_question.hasClass('calculating')){ 360 if (window.animations && window.animations.length > 0) { 361 let animationCount = next_question.attr('data-animatin-count'); 362 if (animationCount !== undefined && window.animations[animationCount]) { 363 window.animations[animationCount].play(); 364 } 365 } 366 } 367 // console.log(active_question_id); 368 // console.log(quiz_count); 369 if(active_question_id == quiz_count) { 370 $('#quiz').submit(); 371 } else { 372 var new_active_question = $('#quiz').find("[data-question-id='" + next_question_id + "']"); 373 active_question.fadeOut(150, function () { 374 new_active_question.fadeIn(150); 375 new_active_question.addClass('question-active'); 376 active_question.removeClass('question-active'); 377 }); 378 if(next_question_id != 1) {
379 $('.back-quiz').css('visibility', 'visible'); 380 } 381 if(new_active_question.attr('data-qzcount')) { 382 $('.current-count').html(new_active_question.attr('data-qzcount')); 383 $('.qz-count').css('visibility', 'visible'); 384 } else { 385 $('.qz-count').css('visibility', 'hidden'); 386 } 387 handle_progress_bar(next_question_id); 388 var custom_url = new_active_question.attr('data-custom-url'); 389 window.history.pushState("", "", '?q=' + custom_url); 390 if (typeof gtag == 'function') { 391 gtag('config', 'UA-200520999-1', {'page_path': '?q=' + custom_url}); 392 } 393 window.scrollTo(0, 0); 394 } 395 } 396 397 function move_to_previous_question(){ 398 var active_question = $('.question-active'), 399 active_question_id = parseInt(active_question.attr('data-question-id')), 400 next_question_id = active_question_id - 1, 401 next_question = $('.question[data-question-id=' + next_question_id + ']'); 402 if(next_question_id == 0) { 403 history.go(-1) 404 } else { 405 406 if(next_question.hasClass('calculating')){ 407 if (window.animations && window.animations.length > 0) { 408 let animationCount = next_question.attr('data-animatin-count'); 409 if (animationCount !== undefined && window.animations[animationCount]) { 410 window.animations[animationCount].goToAndStop(0, true); 411 } 412 } 413 next_question_id = active_question_id - 2; 414 } 415 var new_active_question = $('#quiz').find("[data-question-id='" + next_question_id + "']"); 416 active_question.fadeOut(function(){ 417 new_active_question.fadeIn(); 418 new_active_question.addClass('question-active'); 419 active_question.removeClass('question-active'); 420 }); 421 if(next_question_id == 1) {
422 $('.back-quiz').css('visibility', 'hidden'); 423 } 424 if(new_active_question.attr('data-qzcount')) { 425 $('.current-count').html(new_active_question.attr('data-qzcount')); 426 $('.qz-count').css('visibility', 'visible'); 427 } else { 428 $('.qz-count').css('visibility', 'hidden'); 429 } 430 var custom_url = new_active_question.attr('data-custom-url'); 431 window.history.pushState("", "", '?q=' + custom_url); 432 if (typeof gtag == 'function') { 433 gtag('config', 'UA-200520999-1', {'page_path': '?q=' + custom_url}); 434 } 435 436 } 437 handle_progress_bar(next_question_id); 438 } 439 function handleDots(index){ 440 const circles = document.querySelectorAll('.circle'); 441 circles.forEach((circle, i) => { 442 circle.classList.remove('active', 'visited', 'disabled'); 443 // Apply the correct state based on the index 444 if (i === index) { 445 circle.classList.add('active'); // Current page is active 446 } else if (i < index) { 447 circle.classList.add('visited'); // Pages before are visited 448 } else { 449 circle.classList.add('disabled'); // Pages after are disabled 450 } 451 }); 452 453 } 454 function handleMultiple(index){ 455 if(multipleQuizParts){ 456 const circles = document.querySelectorAll('.circle'); 457 circles.forEach((circle, i) => { 458 circle.classList.remove('active', 'visited', 'disabled'); 459 let foundPart = null; 460 for (const part in multipleQuizParts) { 461 if (multipleQuizParts[part].includes(index)) { 462 foundPart = part; 463 break; 464 } 465 } 466 if (i == foundPart) { 467 circle.classList.add('active'); // Current page is active 468 } else if (i < foundPart) { 469 circle.classList.add('visited'); // Pages before are visited 470 } else { 471 circle.classList.add('disabled'); // Pages after are disabled 472 } 473 }); 474 } 475 476 } 477 function handle_progress_bar(target_question){ 478 let dots = $('.top-line.dots'); 479 let multiple = $('.top-line.multiple'); 480 let alignedIndex = target_question - 1; 481 if(dots.length){ 482 handleDots(alignedIndex); 483 } 484 if(multiple.length){ 485 handleMultiple(alignedIndex); 486 } 487 var progress = 50; 488 $('body').removeClass(function (index, className) { 489 return (className.match(/(^|\s)body-quiz-step-\S+/g) || []).join(' '); 490 }).addClass('body-quiz-step-' + target_question); 491 492 let stepBodyClass = $('#quiz').find("[data-question-id='" + target_question + "']").attr('data-body-class'); 493 if(stepBodyClass){ 494 $('body').removeClass(function (index, className) { 495 return (className.match(/(^|\s)body-class-step-\S+/g) || []).join(' '); 496 }).addClass('body-class-step-' + stepBodyClass); 497 }else{ 498 $('body').removeClass(function (index, className) { 499 return (className.match(/(^|\s)body-class-step-\S+/g) || []).join(' '); 500 }); 501 } 502 503 504 if(target_question == 1) { 505 $('.progress-quiz').addClass('quiz-disabled-progress'); 506 } else { 507 $('.progress-quiz').removeClass('quiz-disabled-progress'); 508 } 509 if(target_question <= 5) { 510 progress = progress + (target_question * 5); 511 } else { 512 progress = 75; 513 var quiz_count = variables.quiz_count, 514 progress_for_each_question = 25 / quiz_count; 515 progress = progress + progress_for_each_question * target_question; 516 } 517 $('.progress-quiz-active').css('width', progress + '%'); 518 } 519 520 $('.step-input').on('input', function(e){ 521 console.log('on step input'); 522 let inputValue = $(this).val();
523 let inputFillElem = $('#input-step-' + $(this).attr('name')); 524 let inputSubmitBtn = $('.step-input-btn-' + $(this).data('step')); 525 let activeStep = $('.question.question-active'); 526 527 let weightGoal = $('#input-step-weight_goal'); 528 let bmiResult = $('.input-step-bmi_result'); 529 let measurments = $('input[name="measurments_target_weight"]:checked').val(); 530 let measurmentsType = $('input[name="measurments_target_weight"]:checked').parent().attr('data-lb'); 531 let currentWeight = $('body input[name="weight"]').val(); 532 let desiredWeight = $('body input[name="desired_weight"]').val(); 533 let height_ft = $('body input[name="height_ft"]').val(); 534 let height_in = $('body input[name="height_in"]').val(); 535 if(measurmentsType && currentWeight){ 536 if(weightGoal && desiredWeight){ 537 weightGoal.text( currentWeight - desiredWeight + ' '+ measurmentsType +''); 538 let currenPoint = $('.step-input-current-point'); 539 let targetPoint = $('.step-input-target-point'); 540 if(currenPoint && targetPoint){ 541 let dates = summaryDates(); 542 currenPoint.html(dates.current + ' <span> ' + currentWeight + ' ' + measurmentsType + ' </span>'); 543 targetPoint.html(dates.final + ' <span> ' + desiredWeight + ' ' + measurmentsType + ' </span>'); 544 } 545 } 546 if(bmiResult){ 547 let height = $('input[name="height_cm"]').val(); 548 let heightInches = 0; 549 if(measurments == 'imperial' ) { 550 551 heightInches = (parseInt(height_ft, 10) * 12) + (parseInt(height_in, 10)); 552 height = parseInt(height_ft, 10) + (parseInt(height_in, 10) * 0.1); 553 } 554 if( ! height && height_ft){ 555 const ft = parseInt(height_ft, 10); 556 const inch = parseInt(height_in, 10) || 0; 557 const heightInInches = (ft * 12) + inch; 558 const heightInCm = heightInInches * 2.54; 559 height = heightInCm; 560 } 561 let summaryinfo = { 562 weight: currentWeight, 563 height: height, 564 heightInches: heightInches, 565 measurments: measurments 566 }; 567 console.log(summaryinfo); 568 let result = summaryCurrentBmi(summaryinfo); 569 console.log(result); // Optional: check the output 570 bmiResult.find('h3').text(result.bmiLabel.label); 571 bmiResult.find('span').text('(' + result.bmi + ')'); 572 $('.quiz-bmi').attr('class', 'quiz-bmi').addClass(result.bmiLabel.label); 573 $('.your-bmi-info').attr('class', 'your-bmi-info').addClass(result.bmiLabel.label); 574 $('div[bmi_value]').attr('bmi_value', result.bmiLabel.label); 575 } 576 } 577 578 if (inputValue.length > 2) { 579 580 if(activeStep.hasClass('question-text-answers')){ 581 let radioTargetElem = activeStep.find('input[type="radio"]'); 582 let radioTarget = activeStep.find('input[type="radio"]:checked'); 583 584 if ( radioTargetElem.length === 0 ) { 585 inputSubmitBtn.removeClass('cta-button-disabled'); 586 }else{ 587 if(radioTarget.length > 0){ 588 inputSubmitBtn.removeClass('cta-button-disabled'); 589 } 590 } 591 } 592 593 }else{ 594 inputSubmitBtn.addClass('cta-button-disabled'); 595 } 596 if(inputFillElem){ 597 inputFillElem.text(inputValue); 598 } 599 600 }); 601 602 $('.answ-hl input').on('change', function(e){ 603 604 let submitItem = $(this).data('submit'); 605 if(submitItem){ 606 $("#quiz").submit(); 607 return; 608 } 609 var parent = $(this).parent(), 610 parent_parent = parent.parent(),
611 numberOfChecked = parent_parent.find('input:checked').length, 612 max = parent.attr('data-max'); 613 parent_parent.find('input:not(:checked)').parent().removeClass('active-box'); 614 parent_parent.find('input:checked').parent().addClass('active-box'); 615 if( ! parent_parent.hasClass('multiple-question') ) { 616 if(numberOfChecked >= max) { 617 if(! parent_parent.hasClass('manual-next')){ 618 move_to_next_question(); 619 } 620 } 621 } 622 623 if(parent_parent.hasClass('multiple-question')) { 624 e.preventDefault(); 625 if($('.question.question-active').hasClass('specific-areas')){ 626 parent_parent.parent().find('.cta-button').removeClass('cta-button-disabled'); 627 }else{ 628 var numberOfChecked = parent_parent.find('input:checked').length; 629 if(numberOfChecked > 0) { 630 let allowNone = $(this).data('none'); 631 if(allowNone && $(this).is(':checked')){ 632 parent_parent.find('input:checked').not($(this)).prop('checked', false).trigger('change'); 633 parent_parent.find('input[data-none=1]').removeClass('clicked'); 634 move_to_next_question(); 635 }else{ 636 let targetItem = parent_parent.find('input[data-none=1]'); 637 if( ! targetItem.hasClass('clicked')){ 638 parent_parent.find('input[data-none=1]:checked').prop('checked', false).trigger('change'); 639 } 640 } 641 if(parent.hasClass('text-by-answer')){ 642 e.preventDefault(); 643 parent_parent.find('input:checked').not($(this)).prop('checked', false); 644 parent_parent.find('input').parent().removeClass('active-box'); 645 if($(this).is(':checked')){ 646 parent.addClass('active-box'); 647 parent_parent.parent().find('.cta-button').removeClass('cta-button-disabled'); 648 649 let selectedId = $(this).attr("id"); 650 $(".wrap-answers-content li").hide(); 651 $(".wrap-answers-content li." + selectedId).show(); 652 } else { 653 parent_parent.parent().find('.cta-button').addClass('cta-button-disabled'); 654 $(".wrap-answers-content li").hide(); 655 } 656 } 657 parent_parent.parent().find('.cta-button').removeClass('cta-button-disabled'); 658 } else { 659 parent_parent.parent().find('.cta-button').addClass('cta-button-disabled'); 660 } 661 } 662 } 663 if(parent.hasClass('star-rating')) { 664 e.preventDefault(); 665 var numberOfChecked = parent_parent.find('input:checked').length; 666 if(numberOfChecked > 0) { 667 parent_parent.parent().find('.cta-button').removeClass('cta-button-disabled'); 668 } else { 669 parent_parent.parent().find('.cta-button').addClass('cta-button-disabled'); 670 } 671 } 672 673 }); 674 675 $('.answ-hl input[data-none=1]').on('click', function(e){ 676 if($(this).is(':checked')){ 677 $(this).addClass('clicked'); 678 }else{ 679 $(this).removeClass('clicked'); 680 } 681 }); 682 683 $('.answ-hl input#form-field-email').on('input keyup change', function(e){ 684 685 var parent = $(this).parent(), 686 parent_parent = parent.parent(); 687 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; 688 689 if(this.value){ 690 if(emailReg.test( this.value )){ 691 parent_parent.parent().find('.cta-button').removeClass('cta-button-disabled'); 692 }else{ 693 parent_parent.parent().find('.cta-button').addClass('cta-button-disabled'); 694 } 695 }else{ 696 parent_parent.parent().find('.cta-button').addClass('cta-button-disabled'); 697 } 698 }); 699 700 701 $('.single-answer-allowed label').on('click', function(e){ 702 var parent = $(this), 703 parent_parent = parent.parent(),
704 numberOfChecked = parent_parent.find('input:checked').length, 705 max = parent.attr('data-max'); 706 parent_parent.find('input:checked').parent().addClass('active-box'); 707 if(numberOfChecked >= max) { 708 if( ! parent_parent.hasClass('manual-next')){ 709 move_to_next_question(); 710 }else{ 711 let activeInput = $('.question.question-active').find('.step-input'); 712 if(activeInput.length > 0){ 713 activeInput.trigger('input'); 714 } 715 } 716 } 717 }); 718 719 $('.imp-m-inputs input').on('change', function(e){ 720 validateMeasurmentsForm(); 721 }); 722 723 $('.imperial-metric input').on('change', function(e){ 724 e.preventDefault(); 725 var type = $(this).parent().attr('data-lb'); 726 $('.imp-label').removeClass('imp-m-active'); 727 if(type == 'lb') { 728 $('.lb-inps').show(); 729 $('.inp-kg').hide(); 730 $('.imp-label:nth-child(1)').addClass('imp-m-active'); 731 $('.imp-label:nth-child(1)').find('input').trigger('click'); 732 } else { 733 $('.lb-inps').hide(); 734 $('.inp-kg').show(); 735 $('.imp-label:nth-child(2)').addClass('imp-m-active'); 736 $('.imp-label:nth-child(2)').find('input').trigger('click'); 737 } 738 $('.change-txt-c').html(type); 739 validateMeasurmentsForm(); 740 }); 741 742 743 $(document).on('submit', '#quiz', function(e){ 744 $('.quiz-loader').fadeIn(); 745 e.preventDefault(); 746 747 let formData = new FormData(this); 748 formData.append('action', 'submit_quiz_form'); 749 750 let hash = $(this).find('input[name="hash"]').val(); 751 let angle = $(this).find('input[name="angle"]').val(); 752 if (hash) { 753 document.cookie = "hash=" + hash + ";path=/;max-age=3600"; 754 } 755 if (angle) { 756 document.cookie = "angle=" + angle + ";path=/;max-age=3600"; 757 } 758 759 $.ajax({ 760 url: variables.ajaxUrl, 761 data: formData, 762 processData: false, 763 contentType: false, 764 type: 'POST', 765 success: function (data) { 766 // console.log(data); 767 // window.location.href = variables.quiz_url; 768 } 769 }); 770 // Wait 1 second, then redirect 771 setTimeout(function() { 772 window.location.href = variables.quiz_url; 773 }, 1000); 774 }); 775 776 let pathname = window.location.pathname; 777 if (pathname.indexOf("wl-quiz3") >= 0) { 778 $("[data-qzcount='20'] label").one('click', function(event) { 779 $('.predict-measurements').remove(); 780 let important_event = $(this).text().trim(); 781 let weight = $("[name='weight']").val(); 782 let desired_weight = $("[name='desired_weight']").val(); 783 let measurement_units = $(".txt-fl.change-txt-c:first").text(); 784 let difference = parseInt(desired_weight) - parseInt(weight); 785 $(".summary-fields").append(' <p class="predict-measurements"><span class="predict-text">We predict youâll be</span><br><span class="weight-line"><span class="weight-event"> for your </span></span><br><span class="difference"></span></p>'); 786 $(".summary-fields").append('<span class="desired-weight-box">'+weight+' '+measurement_units + '</span><span class="current-weight-box">'+desired_weight+' '+measurement_units + '</span>'); 787 788 $("<span>"+desired_weight+" "+measurement_units+"</span>").insertBefore(".weight-event"); 789 $("<span> special event</span>").insertAfter(".weight-event"); 790 $(".difference").append(difference +" "+ measurement_units); 791 }); 792 } 793}); 794 795jQuery(document).ready(function($) { 796 let vidElements = jQuery('.json-video'); 797 window.animations = []; 798 vidElements.each(function() { 799 let videoUrl = jQuery(this).data('video-url'); 800 801 if (videoUrl) { 802 let animItem = bodymovin.loadAnimation({ 803 container: this, 804 renderer: 'svg', 805 loop: false, 806 autoplay: false, 807 path: videoUrl 808 }); 809 animItem.addEventListener('complete', function() { 810 let activeAnimation = $('.question.question-active'); 811 activeAnimation.find('.cta-button').click(); 812 }); 813 window.animations.push(animItem); 814 } 815 }); 816 817 $('input[name=book_cover]').on('change', function(e){ 818 let parent = $(this).parent(); 819 let coverUrl = parent.find('.icon-hover').attr('src'); 820 let labelFor = parent.attr('for'); 821 822 $('.target-wrap').removeClass(function (index, className) { 823 return (className.match(/(^|\s)book_cover\S+/g) || []).join(' '); 824 }).addClass(labelFor); 825 826 $('.target-image').html('<img src="' + coverUrl + '" />'); 827 }); 828 829});
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.