-
Notifications
You must be signed in to change notification settings - Fork 1
/
src.js
46 lines (38 loc) · 1.18 KB
/
src.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
function fisConvert(num) {
var temp, tempActive = false
var inchTrue, footTrue, sixTrue, sixDeci, sixRoun
var foot = 0, inch = 0, six = 0
var fis, result, output
var dec = 0, rem
var history
var errorMsg = 'error'
if(event.keyCode == 13) {
if(num.value === ''){
return [0, errorMsg]
} else
if(!isNaN(num.value)){
temp = num.value
tempActive = false
if(num.value < 0){
temp = num.value * -1
tempActive = true
}
footTrue = temp
inchTrue = temp * 12
sixTrue = inchTrue * 16
sixRoun = Math.round(sixTrue)
foot = Math.floor((sixRoun / 16) / 12)
inch = Math.floor(sixRoun / 16) - (foot * 12)
six = sixRoun - (((foot * 12) + inch) * 16)
dec = sixTrue - sixRoun
fis = foot + '-' + inch + '-' + six
rem = dec.toFixed(2)
if(tempActive){
rem = rem * -1
}
return [fis, rem]
} else {
return [2, errorMsg]
}
}
}