UNPKG

co2offset

Version:

Greenhouse Gas Accounting - ISO14064

1 lines 1.91 kB
void 0===window.app&&(window.app={});const app=async function(){function t(){a.consumption=$("#m2").val()*$("#kwh").val()*$("#factor").val()/1e3,$("#consumption").val(a.consumption),$("#operatingfactor").val(a.operatingfactor),a.scope1=a.consumption*$("#factor").val()/a.operatingfactor,a.presafing=a.consumption*$("#factor").val()-a.scope1,$("#factor").val(a.factor),$(".presafing").html(window.app.formatGrams(a.presafing)),$(".scope1").html(window.app.formatGrams(a.scope1)),$(".scope2").html(window.app.formatGrams(a.scope2)),$(".scope3").html(window.app.formatGrams(a.scope3))}let a={presafing:0,operatingfactor:1,scope1:0,scope2:0,scope3:0,consumption:2300,factor:294};$("#hdrInfo").hide(),$(".hdrinfo").hide();let e=await window.co2accounting.keyValue();void 0!==e.nature&&("Household"==e.nature&&(a.m2=80),"Person"==e.nature&&(a.m2=45),"Company"==e.nature&&(a.m2=200)),t(),$("#factorSelector").change((function(e){a.factor=1*$(this).val(),t()})),$("#consumption").change((function(e){a.consumption=1*$(this).val(),t()})),$("#operatingfactor").change((function(e){a.operatingfactor=1*$(this).val(),t()})),$("#m2").change(t),$("#kwh").change(t),$("#startTime").val(new Date((new Date).getTime()-31536e6).toISOString().substr(0,10)),$("#endTime").val((new Date).toISOString().substr(0,10)),$("#heating_data").submit((function(t){!async function(t){let a=await window.co2accounting.keyValue();void 0!==a.heating_event&&await window.co2accounting.eventDelete(a.heating_event);let e={heating_event:(await window.co2accounting.settleEvent(t)).event};await window.co2accounting.keyValue(e),window.app.clearCache(),location.href="./index.html"}({title:"Heating",qty:a.consumption,presafing:a.presafing,factor:a.factor,co2:a.scope1,co2eq:a.scope1,unit:"kWh",scope:"1",category:"Heating",startTime:new Date($("#startTime").val()).getTime(),endTime:new Date($("#endTime").val()).getTime()}),t.preventDefault()}))};