diff --git a/src/main/resources/static/js/home.js b/src/main/resources/static/js/home.js index 9c2bd878..0163968e 100644 --- a/src/main/resources/static/js/home.js +++ b/src/main/resources/static/js/home.js @@ -372,47 +372,58 @@ function populateSummaryDiv() { bpNote.addClass('crisis'); bpNote.show(); - } else if (avgSystolic === 0) { // not enough readings to compute average - // Add the placeholder image and text - bpPlaceholder.show(); - bpPlaceholder.append("Enter more blood pressures to see average"); - bpPlaceholder.append("
Enter more blood pressures to see average
"); - } else if (isBasic()) { removeBootstrapCols(bpIndicatorContainer); chartContainer.hide(); bpIcon.hide(); bpNote.hide(); - bpPlaceholder.hide(); - bpContainer.show(); - bpLabel.html('Most Recent BP:'); - bpLabel.show(); - systolic.html(mostRecentBP.systolic.value); - systolic.removeClass('crisis'); - diastolic.html(mostRecentBP.diastolic.value); - diastolic.removeClass('crisis'); + if (mostRecentBP.systolic === undefined || mostRecentBP.diastolic === undefined) { + bpPlaceholder.html("
No blood pressures to display
"); + bpPlaceholder.show(); + bpContainer.hide(); - } else if (isEnhanced()) { - if (aboveGoal) { - bpIcon.html("Above GoalYour average BP is above goal. Average is calculated based on a maximum of 12 recent readings. Check the Resources tab to learn more about what to do."); - bpNote.html('Your BP is above your goal!'); } else { - bpIcon.html("At or Below GoalYour average BP is at goal. Average is calculated based on a maximum of 12 recent readings. Check the Resources tab to learn more about what to do."); - bpNote.html('You reached your goal!'); + bpPlaceholder.hide(); + bpContainer.show(); + bpLabel.html('Most Recent BP:'); + bpLabel.show(); + bpContainer.show(); + systolic.html(mostRecentBP.systolic.value); + systolic.removeClass('crisis'); + diastolic.html(mostRecentBP.diastolic.value); + diastolic.removeClass('crisis'); } - bpIcon.show(); - bpNote.removeClass('crisis'); - bpNote.show(); - bpPlaceholder.hide(); - bpContainer.show(); + } else if (isEnhanced()) { + if (avgSystolic === 0) { // not enough readings to compute average + // Add the placeholder image and text + bpPlaceholder.show(); + bpPlaceholder.append("Enter more blood pressures to see average"); + bpPlaceholder.append("
Enter more blood pressures to see average
"); + + } else { + if (aboveGoal) { + bpIcon.html("Above GoalYour average BP is above goal. Average is calculated based on a maximum of 12 recent readings. Check the Resources tab to learn more about what to do."); + bpNote.html('Your BP is above your goal!'); + } else { + bpIcon.html("At or Below GoalYour average BP is at goal. Average is calculated based on a maximum of 12 recent readings. Check the Resources tab to learn more about what to do."); + bpNote.html('You reached your goal!'); + } + + bpIcon.show(); + bpNote.removeClass('crisis'); + bpNote.show(); + bpPlaceholder.hide(); + bpContainer.show(); + + bpLabel.html('Recent BP Average:').attr('title', 'Average of the last several readings shaded in grey'); + systolic.html(avgSystolic); + systolic.removeClass('crisis'); + diastolic.html(avgDiastolic); + diastolic.removeClass('crisis'); + } - bpLabel.html('Recent BP Average:').attr('title', 'Average of the last several readings shaded in grey'); - systolic.html(avgSystolic); - systolic.removeClass('crisis'); - diastolic.html(avgDiastolic); - diastolic.removeClass('crisis'); } else { console.error("Unexpected randomization group") }