-
Notifications
You must be signed in to change notification settings - Fork 0
/
weight.js
44 lines (36 loc) · 830 Bytes
/
weight.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
function urlParams() {
return window.location.search
.substring( 1 )
.split( "&" )
.reduce( function ( params, param ) {
if ( param ) {
var pair = param.split( "=" );
params[ pair[ 0 ] ] = pair[ 1 ];
}
return params;
}, {} );
}
function defaultKg() {
var kg = urlParams().kg;
if ( isNaN( kg ) ) {
return "";
}
return kg;
}
function kg2st( kg ) {
return kg / 6.3503;
}
function kg2stlb( kb ) {
var st = kg2st( kb );
return {
"st": Math.trunc( st ),
"lb": 14 * ( st - Math.trunc( st ) )
};
}
function wordykg2stlb( kg ) {
if ( isNaN( kg ) ) {
return "";
}
var stlb = kg2stlb( kg );
return stlb.st + " st " + stlb.lb.toFixed( 1 ) + " lb";
}