-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
56 lines (45 loc) · 1.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
function slider() {
var value = document.getElementById("amount").value;
document.getElementById("value").innerHTML = parse_value(value);
document.getElementById("eco").innerHTML = parse_value(value * 0.06 - 1700)
}
function parse_value(value) {
return first(value) + second(value) + third(value);
}
function first(value) {
var calc = this.quotient(value, 1000000);
var result = '';
if (calc != 0) {
result = calc + ' ';
}
return result;
}
function second(value) {
var calc = this.quotient(value % 1000000, 1000);
var result = '';
if (calc >= 0 && value >= 1000000) {
if (calc > 99) {
result = calc + ' ';
}
else if (calc > 9) {
result = '0' + calc + ' ';
}
else {
result = '00' + calc + ' ';
}
} else if (calc >= 0) {
result = calc + ' ';
}
return result;
}
function third(value) {
var calc = this.quotient(value % 1000, 1);
var result = '000';
if (calc != 0) {
result = calc + ' ';
}
return result;
}
function quotient(dividend, dividers) {
return (dividend - dividend % dividers) / dividers;
}