-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsalaryCalculator.js
More file actions
47 lines (42 loc) · 1.88 KB
/
Copy pathsalaryCalculator.js
File metadata and controls
47 lines (42 loc) · 1.88 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
var numberOfEstaff = document.getElementById("EstaffAmount").value;
var numberOfManagers = document.getElementById("ManagerAmount").value;
var numberOfEmployees = document.getElementById("EmployeeAmount").value;
var numberOfInterns = document.getElementById("InternAmount").value;
var salaryRunner; // to keep track of our salary event
var previousSalary = 0;
/**
* Will get a salary per second, given
* a yearly salary. Assumes 8 hours a day
* and 240 work days (260 less holidays
* and 2 weeks vacation). */
function getSalaryPerSecond(salary) {
return ((((salary / 240) / 8) / 60) / 60);
}
/**
* Will calculate a running salary.
* Assumes the following salaries:
* E-Staff: 200k/yr
* Managers: 140k/yr
* Employees: 70k/yr
* Interns: 35k/yr */
function calculateSalary() {
numberOfEstaff = document.getElementById("EstaffAmount").value;
numberOfManagers = document.getElementById("ManagerAmount").value;
numberOfEmployees = document.getElementById("EmployeeAmount").value;
numberOfInterns = document.getElementById("InternAmount").value;
var totPerSecond = (numberOfEstaff * getSalaryPerSecond(200000)) + (numberOfManagers * getSalaryPerSecond(140000)) + (numberOfEmployees * getSalaryPerSecond(70000)) + (numberOfInterns * getSalaryPerSecond(35000));
previousSalary += totPerSecond;
document.getElementById("CurrentSalary").innerText = "Total Meeting Cost: $" + previousSalary.toFixed(2);
document.getElementById("CurrentCostPerMinute").innerText = "Cost Per Minute: $" + (totPerSecond * 60).toFixed(2);
}
document.getElementById("CalculateSalary").addEventListener("click", function () {
if (salaryRunner) {
clearInterval(salaryRunner);
salaryRunner = null;
this.innerText = "Calculate Meeting Salary";
}
else {
salaryRunner = setInterval(calculateSalary, 1000);
this.innerText = "Stop Calculating Salary";
}
});