39 lines
851 B
JavaScript
39 lines
851 B
JavaScript
window.loadCosts = async function(){
|
|
|
|
const resources = window.resources || []
|
|
const domains = await api(API + "/domains")
|
|
|
|
let month = 0
|
|
let year = 0
|
|
let domainYear = 0
|
|
|
|
resources.forEach(r => {
|
|
|
|
if(r.kosten_monat){
|
|
month += parseFloat(r.kosten_monat)
|
|
}
|
|
|
|
if(r.kosten_jahr){
|
|
year += parseFloat(r.kosten_jahr)
|
|
}
|
|
|
|
})
|
|
|
|
domains.forEach(d => {
|
|
|
|
if(d.yearly_cost){
|
|
domainYear += parseFloat(d.yearly_cost)
|
|
}
|
|
|
|
})
|
|
|
|
document.getElementById("costMonth").innerText = month.toFixed(2)
|
|
document.getElementById("costYear").innerText = year.toFixed(2)
|
|
document.getElementById("costDomain").innerText = domainYear.toFixed(2)
|
|
|
|
const total = year + domainYear
|
|
|
|
document.getElementById("costTotal").innerText = total.toFixed(2)
|
|
|
|
}
|