UNPKG

co2offset.io

Version:

Greenhouse Gas Accounting - ISO14064

1 lines 6.91 kB
void 0===window.app&&(window.app={});const app=async function(){Chart.register(ChartDataLabels);let e=await(await window.co2accounting.keyValue());void 0!==e.account_name&&($("#reportingName").html(e.account_name),$("#reportingName").show()),void 0!==e.nature&&($("#reportingType").html(e.nature+"&nbsp;Greenhouse Gas&nbsp;reporting"),$("#reportingType").show()),widget_inventory(),void 0===window.app._spare&&(window.app._spare=1),$(".overview_current").click((function(e){window.app._spare="now",app(),e.preventDefault()})),$(".overview_year").click((function(e){window.app._spare="yr",app(),e.preventDefault()})),$("#searchFrm").submit((function(e){window.app.renderSearchResults(),e.preventDefault()})),$.ajax({url:"../assets/img/scopes.svg",type:"GET",dataType:"text"}).done((async function(e){if(e=e.substr(e.indexOf("<svg")),window.datasvg=e,void 0!==window.datasvg){let e=await window.app.renderCertificates(),s={},a={VER:0,LSTCC:0};for(let t=0;t<e.length;t++)try{void 0===s[e[t].gsc.tx.from]&&(s[e[t].gsc.tx.from]={type:"Voluntary Emission Reduction (VER)",co2:0,events:0,identity:e[t].gsc.tx.from}),s[e[t].gsc.tx.from].co2+=e[t].co2requested,a.VER+=e[t].co2requested,s[e[t].gsc.tx.from].events++,void 0===s[e[t].certificate.tree]&&(s[e[t].certificate.tree]={type:"Certified Long- to Short-Term-Carbon-Cycle Conversation (LSTCC)",co2:0,events:0,identity:e[t].certificate.tree}),s[e[t].certificate.tree].co2+=e[t].co2,a.LSTCC+=e[t].co2,s[e[t].certificate.tree].events++}catch(e){}a.LSTCC,a.VER;let t=0;for(const[e,a]of Object.entries(s))a.co2>t&&(t=a.co2);let o=await window.co2accounting.balance({subbalances:!0});void 0===o.isAlias&&window.co2accounting.isOnline?$("#viewOnlyAlert").hide():($("#viewOnlyAlert").show(),$("#accordionSidebar").hide(),$("#loginNav").show());let i={labels:[],datasets:[{label:"Scopes",data:[],backgroundColor:[]}]},n={SCOPE1:0,SCOPE2:0,SCOPE3:0,SCOPE1A:0,SCOPE2A:0,SCOPE3A:0,SCOPE1B:0,SCOPE2B:0,SCOPE3B:0,BALANCE:o.liabilities+-1*a.VER,CREDITS:-1*a.VER,PSAFING:-1*o.presafings,LIABILITIES:o.liabilities},r=0,c=[];t=0;for(const[e,s]of Object.entries(n))isNaN(s)||(c.push(Math.abs(s)),Math.abs(s)>t&&(t=Math.abs(s)));$(".balance_balance").html(window.app.formatGrams(o.liabilities+-1*a.VER,t)),$(".balance_assets").html(window.app.formatGrams(-1*a.VER*1,t)),$(".balance_liabilities").html(window.app.formatGrams(1*o.liabilities,t)),$(".balance_presafings").html(window.app.formatGrams(-1*o.presafings,t));let l=(o.liabilities-1*a.VER)/$(".totalYearly").attr("data"),p=1;"yr"==window.app._spare?(p=$(".totalYearly").attr("data")/31536e6,$("#projInfo").html("&nbsp;-&nbsp;Projection Year")):$("#projInfo").html(""),void 0!==o.subbalances.scopes.scope_1&&(n.SCOPE1=o.subbalances.scopes.scope_1.liabilities,n.SCOPE1A=-1*o.subbalances.scopes.scope_1.assets,n.SCOPE1B=-1*o.subbalances.scopes.scope_1.balance,i.labels.push("Scope 1"),i.datasets[0].data.push(o.subbalances.scopes.scope_1.liabilities*p),i.datasets[0].backgroundColor.push("#CCCCCC"),r+=o.subbalances.scopes.scope_1.liabilities),void 0!==o.subbalances.scopes.scope_2&&(n.SCOPE2=o.subbalances.scopes.scope_2.liabilities,n.SCOPE2A=-1*o.subbalances.scopes.scope_2.assets,n.SCOPE2B=-1*o.subbalances.scopes.scope_2.balance,i.labels.push("Scope 2"),i.datasets[0].data.push(o.subbalances.scopes.scope_2.liabilities*p),i.datasets[0].backgroundColor.push("#D5E8D4"),r+=o.subbalances.scopes.scope_2.liabilities),void 0!==o.subbalances.scopes.scope_3&&(n.SCOPE3=o.subbalances.scopes.scope_3.liabilities,n.SCOPE3A=-1*o.subbalances.scopes.scope_3.assets,n.SCOPE3B=-1*o.subbalances.scopes.scope_3.balance,i.labels.push("Scope 3"),i.datasets[0].data.push(o.subbalances.scopes.scope_3.liabilities*p),i.datasets[0].backgroundColor.push("#9AC7BF"),r+=o.subbalances.scopes.scope_3.liabilities);let d=0;for(const[e,s]of Object.entries(n)){let a=s/p;a>d&&(d=a),n[e]=window.app.formatGrams(a,d)}let b="<p>Total emissions by reporting entity are <strong>"+window.app.formatGrams(o.presafings+o.liabilities,t)+'</strong> <span class="text-muted">(Pre Safing Upstream+ Emitted)</span> with a balance of <strong>'+window.app.formatGrams(-1*a.VER+o.liabilities,t)+"</strong> after compensation/offset.</p>";b+='<h5>Pre Safings: <strong style="color:#BAA743">-'+window.app.formatGrams(o.presafings,t)+"</strong></h5><p>Indirectly avoided upstream Greenhouse Gas emission by choosing an alternative product/variation. </p>",void 0!==o.subbalances.scopes.scope_1&&(b+='<h5>Scope 1: <strong style="color:#A3A3A3">'+n.SCOPE1+"</strong></h5><p>Emissions from sources directly owned or controlled by reporting entity (e.g. operation of own boiler or vehicle fleet).</p>"),void 0!==o.subbalances.scopes.scope_2&&(b+='<h5>Scope 2: <strong style="color:#B4C4B3">'+n.SCOPE2+"</strong></h5><p>Upstream indirect Greenhouse Gas emissions from consumption of purchased electricity, heat, cooling or steam.</p>"),void 0!==o.subbalances.scopes.scope_3&&(b+='<h5>Scope 3: <strong style="color:#7CA19A">'+n.SCOPE3+"</strong></h5><p>Value Chain emission, indirect emissions, such as the extraction and production of purchased materials and fuels, transport-related activities in vehicles not owned or controlled by the reporting entity, electricity-related activities).</p>"),b+='<h5>Downstream Liability: <strong style="color:#ADC9A9">'+window.app.formatGrams(o.liabilities,t)+"</strong></h5><p>Greenhouse Gas emissisions caused by the activity of reporting entity. Consists of the sum of Scope 1-3 inculding direct and indirect emissions excluding presafings.</p>",b+='<h5>Voluntary Emission Reduction: <strong style="color:#437510">-'+window.app.formatGrams(a.VER,t)+"</strong></h5><p>Through Verified Emission Reductions, reporting entity voluntarily compensates for its emissions and provides an additional contribution to mitigating climate change (verified Gold Standard).",b+=" In addition, the same amount (additional offset: "+window.app.formatGrams(a.VER,t)+") was used to support reforestation projects under a Long-Short-Term Carbon Cycle Conversation.</p>",$("#prosa").html(b),$("#consensusSVG").html(window.app.parseMustache(window.datasvg,n)),isFinite(-1*l)&&$(".neutralUntil").html(new Date($(".allHighTime").attr("data")-Math.round(31536e6*l)).toLocaleString());const u={type:"doughnut",data:i,options:{responsive:!0,onClick:function(e,s){console.log(s)},plugins:{legend:{position:"top"},title:{display:!1,text:""},tooltip:{callbacks:{label:e=>e.label+": "+window.app.formatGrams(e.parsed)+" ("+Math.round(e.parsed/o.liabilities*100)+"%)"}},datalabels:{formatter:function(e,s){return 0!==r?s.chart.data.labels[s.dataIndex]+":\n"+window.app.formatGrams(e,t)+" ("+Math.round(e/r*100)+"%)":s.chart.data.labels[s.dataIndex]}}},elements:{center:{text:"Red is 2/3 the total numbers",color:"#FF6384",fontStyle:"Arial",sidePadding:20,minFontSize:20,lineHeight:25}}}};try{new Chart(document.getElementById("scopechart"),u)}catch(e){console.log(e)}}}))};