-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinline_script_6.js
More file actions
143 lines (64 loc) · 3 KB
/
inline_script_6.js
File metadata and controls
143 lines (64 loc) · 3 KB
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
function convertC2CtoW2() {
var c2c = parseFloat(document.getElementById('c2cRate').value) || 0;
if (c2c < 0) c2c = 0;
document.getElementById('w2Rate').value = (c2c * 1.15).toFixed(2);
document.getElementById('1099Rate').value = c2c.toFixed(2);
document.getElementById('annualSalary').value = (c2c * 2080).toFixed(2);
updateLabels();
checkAllZeros();
}
function convertW2toC2C() {
var w2 = parseFloat(document.getElementById('w2Rate').value) || 0;
if (w2 < 0) w2 = 0;
var c2c = w2 / 1.15;
document.getElementById('c2cRate').value = c2c.toFixed(2);
document.getElementById('1099Rate').value = c2c.toFixed(2);
document.getElementById('annualSalary').value = (c2c * 2080).toFixed(2);
updateLabels();
checkAllZeros();
}
function convert1099() {
var val = parseFloat(document.getElementById('1099Rate').value) || 0;
if (val < 0) val = 0;
document.getElementById('w2Rate').value = (val * 1.15).toFixed(2);
document.getElementById('c2cRate').value = val.toFixed(2);
document.getElementById('annualSalary').value = (val * 2080).toFixed(2);
updateLabels();
checkAllZeros();
}
function convertAnnualSalary() {
var salary = parseFloat(document.getElementById('annualSalary').value) || 0;
if (salary < 0) salary = 0;
var c2c = salary / 2080;
document.getElementById('c2cRate').value = c2c.toFixed(2);
document.getElementById('w2Rate').value = (c2c * 1.15).toFixed(2);
document.getElementById('1099Rate').value = c2c.toFixed(2);
updateLabels();
checkAllZeros();
}
function updateLabels() {
var c2c = parseFloat(document.getElementById('c2cRate').value) || 0;
var w2 = parseFloat(document.getElementById('w2Rate').value) || 0;
var _1099 = parseFloat(document.getElementById('1099Rate').value) || 0;
var salary = parseFloat(document.getElementById('annualSalary').value) || 0;
document.getElementById('c2cLabel').innerText = c2c ? `C2C Rate: $${c2c.toFixed(2)}/hr` : "C2C Rate";
document.getElementById('w2Label').innerText = w2 ? `W2 Rate: $${w2.toFixed(2)}/hr` : "W2 Rate";
document.getElementById('1099Label').innerText = _1099 ? `1099 Rate: $${_1099.toFixed(2)}/hr` : "1099 Rate";
document.getElementById('salaryLabel').innerText = salary ? `Salary: $${salary.toFixed(2)}/Yearly` : "Annual Salary";
}
function clearAllFields() {
document.getElementById('c2cRate').value = '';
document.getElementById('w2Rate').value = '';
document.getElementById('1099Rate').value = '';
document.getElementById('annualSalary').value = '';
updateLabels();
}
function checkAllZeros() {
var c2c = parseFloat(document.getElementById('c2cRate').value) || 0;
var w2 = parseFloat(document.getElementById('w2Rate').value) || 0;
var _1099 = parseFloat(document.getElementById('1099Rate').value) || 0;
var salary = parseFloat(document.getElementById('annualSalary').value) || 0;
if (c2c === 0 && w2 === 0 && _1099 === 0 && salary === 0) {
clearAllFields();
}
}