$( "#af #take-survey" ).on("click",function( event ) { $(this).parent().hide(); $(this).parent().next().fadeIn(); event.preventDefault(); }); $( "#af #start" ).on("click",function( event ) { if( $("#af #ack").is(':checked') ){ $(this).parent().hide(); $(this).parent().next().fadeIn(); } else { alert("Please acknowledge that you have read and understood the information provided above by checking the checkbox."); } event.preventDefault(); }); $( "#af #ref" ).on("click",function( event ) { $(this).parent().parent().hide(); $(this).parent().parent().next().fadeIn(); event.preventDefault(); }); $( "#af .back" ).on("click",function( event ) { $(this).parent().parent().hide(); $(this).parent().parent().prev().fadeIn(); event.preventDefault(); }); $( "#af .next" ).on("click",function( event ) { var score = 0; if ( $(this).hasClass("age") ) { var age = $("#af #age").find(":selected").val(); if ( age != "" ) { $(this).parent().parent().hide(); $(this).parent().parent().next().fadeIn(); if ( age <= 39 ) { score = 0; } else if ( age > 39 && age <= 64 ) { score = 1; } else if ( age > 64 ) { score = 3; } $(this).parent().find(".score").val(score); } else { alert("Please select your age."); } } if ( $(this).hasClass("select") ) { if ( $(this).parent().parent().find("input:checked").length != 0 ) { $(this).parent().parent().hide(); $(this).parent().parent().next().fadeIn(); $(this).parent().parent().find("input:checked").each(function( index ) { score += parseInt($(this).data("score")); console.log(parseInt($(this).data("score"))); }); $(this).parent().find(".score").val(score); } else { alert("Please answer the question."); } } if ( $(this).hasClass("bmi") ) { var bmi = $( "#af #bmi span:eq(0)" ).text(); if ( bmi != "" ) { if ( bmi >= 18.5 && bmi <= 24.9 ) { score = 0; } else if ( bmi >= 25 && bmi <= 29.9 ) { score = 2; } else if ( bmi >= 30 ) { score = 4; } $(this).parent().find(".score").val(score); $(this).parent().parent().hide(); $(this).parent().parent().next().fadeIn(); } else { alert("Please calculate your BMI."); } } if ( $(this).hasClass("last") ) { var final_score = 0; $("#af .step").each(function( index ) { if ( $(this).find(".score").length && $(this).find(".score").val() != "" ) { final_score += parseInt($(this).find(".score").val()); } }); if ( final_score <= 3 ) { $("#af #res").html("LOW"); $("#af #res-desc").text("A low-risk score for atrial fibrillation (AFib) means your chances of developing AFib are lower than those with medium or high-risk scores. However, it doesn't eliminate the possibility of AFib entirely. To address any concerns, seek advice from a healthcare professional for personalized guidance and informed decisions about your heart health."); } else { $("#af #res").html("MEDIUM/HIGH"); $("#af #res-desc").text("Medium/high risk for atrial fibrillation (AFib) means you have a higher chance of having AFib. Seeking further evaluation and guidance from a healthcare professional is crucial. Diagnosing AFib early and taking action can have a significant positive impact on your health and reduce the risk of complications. Don't hesitate to consult with a healthcare professional to ensure proper management and minimize potential health risks."); } } event.preventDefault(); }); $("#af #weight_unit, #af #height_unit").on('change', function() { calculate_bmi(); }); $("#af #weight,#af #height").bind('keyup mouseup', function () { calculate_bmi(); }); function calculate_bmi() { var weight_unit = $("#af #weight_unit").find(":selected").val(); var height_unit = $("#af #height_unit").find(":selected").val(); var weight = ( weight_unit == "KG" ) ? $("#af #weight").val() : $("#af #weight").val() / 2.205; var height = ( height_unit == "CM" ) ? $("#af #height").val() / 100 : $("#af #height").val() * 2.54 / 100 ; var bmi = Math.round( weight / (height*height) ); var text; if ( bmi >= 18.5 && bmi <= 24.9 ) { text = "(Normal)"; } else if ( bmi >= 25 && bmi <= 29.9 ) { text = "(Overweight)"; } else if ( bmi >= 30 ) { text = "(Obese)"; } if ( bmi > 0 && bmi != "Infinity") { $("#af #bmi span:eq(0)").text(bmi); $("#af #bmi span:eq(1)").text(text); } }