-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
56 lines (50 loc) · 1.69 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
const limit = 3000000;
const app = document.querySelector('#app');
let fizu = 100000;
let levonasok = 50000;
let teljesFizuHonap = 12.0;
let teljesFizu = fizu;
let buntiFizuHonap = 0.0;
let buntiFizu = 0;
let atlagFizu = teljesFizu;
const bevetelInput = document.querySelector('#bevetel');
const updateBevetel = function () {
fizu = this.value;
updateTableData();
};
bevetelInput.addEventListener('keyup', updateBevetel);
bevetelInput.addEventListener('change', updateBevetel);
const levonasokInput = document.querySelector('#levonasok');
const updateLevonasok = function () {
levonasok = this.value;
updateTableData();
};
levonasokInput.addEventListener('keyup', updateLevonasok);
levonasokInput.addEventListener('change', updateLevonasok);
function updateFizu() {
teljesFizuHonap = limit / fizu > 12 ? teljesFizuHonap : limit / fizu;
buntiFizuHonap = 12 - teljesFizuHonap;
teljesFizu = fizu - levonasok;
atlagFizu = teljesFizu;
if (fizu > limit / 12) {
const limitFelettiFizu = (12 * fizu - limit) * 0.71432;
buntiFizu = (limitFelettiFizu / buntiFizuHonap).toFixed(0) - levonasok;
atlagFizu = ((limit + limitFelettiFizu) / 12).toFixed(0) - levonasok;
}
}
function updateTableData() {
updateFizu();
document.querySelector('#teljes-fizetes').innerText = teljesFizu;
document.querySelector('#teljes-honap').innerText = teljesFizuHonap.toFixed(
1
);
document.querySelector('#bunti-fizetes').innerText = buntiFizu;
document.querySelector('#bunti-honap').innerText = buntiFizuHonap.toFixed(1);
document.querySelector('#atlag-fizetes').innerText = atlagFizu;
}
function init() {
bevetelInput.value = fizu;
levonasokInput.value = levonasok;
updateTableData();
}
init();