-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
79 lines (71 loc) · 3.17 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var rangeSlider = function(){
var slider = $('.row'),
range = $('.value_range'),
value = $('.field-text');
slider.each(function(){
value.each(function(){
var value = $(this).prev().attr('value');
$(this).html(value);
});
range.on('input', function(){
$(this).next(value).html(this.value);
});
});
};
rangeSlider();
$('#submit').click(function(){
var h = $('#height').val() / 100;
var w = $('#weight').val();
var bmi = h * h ;
bmi = w/bmi;
bmi = (bmi).toFixed(1);
$('#bmiValue').html(bmi + " ");
if (bmi < 18.5) {
//Underweight
$('.result-text').css('background','-webkit-linear-gradient(left top, #27939D, #07658F)');
$('.result-text').css('background','-o-linear-gradient(bottom right, #27939D, #07658F)');
$('.result-text').css('background','-moz-linear-gradient(bottom right, #27939D, #07658F)');
$('.result-text').css('background','linear-gradient(to bottom right, #27939D, #07658F)');
$('#bmid').html("Underweight");
} else if ((18.5 <= bmi) && (bmi <= 24.9)) {
//Normal weight
$('.result-text').css('background','-webkit-linear-gradient(left top, #4FD24D, #4CA456)');
$('.result-text').css('background','-o-linear-gradient(bottom right, #4FD24D, #4CA456)');
$('.result-text').css('background','-moz-linear-gradient(bottom right, #4FD24D, #4CA456)');
$('.result-text').css('background','linear-gradient(to bottom right, #4FD24D, #4CA456)');
$('#bmid').html("Normal");
} else if ((25 <= bmi) && (bmi <= 29.9)) {
//Overweight
$('.result-text').css('background','-webkit-linear-gradient(left top, #EF7532, #DC3A26)');
$('.result-text').css('background','-o-linear-gradient(bottom right, #EF7532, #DC3A26)');
$('.result-text').css('background','-moz-linear-gradient(bottom right, #EF7532, #DC3A26)');
$('.result-text').css('background','linear-gradient(to bottom right, #EF7532, #DC3A26)');
$('#bmid').html("Overweight");
} else {
//Obese
$('.result-text').css('background','-webkit-linear-gradient(left top, #F73946, #FF3875)');
$('.result-text').css('background','-o-linear-gradient(bottom right, #F73946, #FF3875)');
$('.result-text').css('background','-moz-linear-gradient(bottom right, #F73946, #FF3875)');
$('.result-text').css('background','linear-gradient(to bottom right, #F73946, #FF3875)');
$('#bmid').html("Obese");
}
console.log(bmi);
});
$('input[type="range"]').change(function () {
var val = ($(this).val() - $(this).attr('min')) / ($(this).attr('max') - $(this).attr('min'));
$(this).css('background-image',
'-webkit-gradient(linear, left top, right top, '
+ 'color-stop(' + val + ', #F73946), '
+ 'color-stop(' + val + ', #27283A)'
+ ')'
);
});
$('.value_range').each(function (){
var val = ($(this).val() - $(this).attr('min')) / ($(this).attr('max') - $(this).attr('min'));
$(this).css('background-image',
'-webkit-gradient(linear, left top, right top, '
+ 'color-stop(' + val + ', #F73946), '
+ 'color-stop(' + val + ', #27283A)'
+ ')'
);
});