co2offset
Version:
Greenhouse Gas Accounting - ISO14064
1 lines • 7.58 kB
JavaScript
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+" Greenhouse Gas 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(s){if(s=s.substr(s.indexOf("<svg")),window.datasvg=s,void 0!==window.datasvg){let s=await window.app.renderCertificates(),a={},t={VER:0,LSTCC:0};for(let e=0;e<s.length;e++)try{void 0===a[s[e].gsc.tx.from]&&(a[s[e].gsc.tx.from]={type:"Voluntary Emission Reduction (VER)",co2:0,events:0,identity:s[e].gsc.tx.from}),a[s[e].gsc.tx.from].co2+=s[e].co2requested,t.VER+=s[e].co2requested,a[s[e].gsc.tx.from].events++,void 0===a[s[e].certificate.tree]&&(a[s[e].certificate.tree]={type:"Certified Long- to Short-Term-Carbon-Cycle Conversation (LSTCC)",co2:0,events:0,identity:s[e].certificate.tree}),a[s[e].certificate.tree].co2+=s[e].co2,t.LSTCC+=s[e].co2,a[s[e].certificate.tree].events++}catch(e){}t.LSTCC,t.VER;let o=0;for(const[e,s]of Object.entries(a))s.co2>o&&(o=s.co2);let i=await window.co2accounting.balance({subbalances:!0});void 0===i.isAlias&&window.co2accounting.isOnline?($("#viewOnlyAlert").hide(),$(".isView").hide(),$(".isAccount").show(),void 0===e.welcome_msg&&window.app.showMsg('<strong>Message:</strong> Welcome to your CO<sub>2</sub> Accounting... <a href="./welcome.html">read more</a>')):($("#viewOnlyAlert").show(),$("#accordionSidebar").hide(),$("#loginNav").show(),$("#navDashboard").show(),$("#navPledge").show(),$(".isAccount").hide(),$(".isView").show());let n={labels:[],datasets:[{label:"Scopes",data:[],backgroundColor:[]}]},r={SCOPE1:0,SCOPE2:0,SCOPE3:0,SCOPE1A:0,SCOPE2A:0,SCOPE3A:0,SCOPE1B:0,SCOPE2B:0,SCOPE3B:0,BALANCE:i.liabilities+-1*t.VER,CREDITS:-1*t.VER,PSAFING:-1*i.presafings,LIABILITIES:i.liabilities},c=0,l=[];o=0;for(const[e,s]of Object.entries(r))isNaN(s)||(l.push(Math.abs(s)),Math.abs(s)>o&&(o=Math.abs(s)));$(".balance_balance").html(window.app.formatGrams(i.liabilities+-1*t.VER,o)),$(".balance_assets").html(window.app.formatGrams(-1*t.VER*1,o)),$(".balance_liabilities").html(window.app.formatGrams(1*i.liabilities,o)),$(".balance_presafings").html(window.app.formatGrams(-1*i.presafings,o));let p=(i.liabilities-1*t.VER)/$(".totalYearly").attr("data"),d=1;"yr"==window.app._spare?(d=1/31536e3*$(".totalYearly").attr("data"),$("#projInfo").html(" - Projection Year")):$("#projInfo").html(""),void 0!==i.subbalances.scopes.scope_1&&(r.SCOPE1=i.subbalances.scopes.scope_1.liabilities,r.SCOPE1A=-1*i.subbalances.scopes.scope_1.assets,r.SCOPE1B=-1*i.subbalances.scopes.scope_1.balance,n.labels.push("Scope 1"),n.datasets[0].data.push(i.subbalances.scopes.scope_1.liabilities*d),n.datasets[0].backgroundColor.push("#CCCCCC"),c+=i.subbalances.scopes.scope_1.liabilities),void 0!==i.subbalances.scopes.scope_2&&(r.SCOPE2=i.subbalances.scopes.scope_2.liabilities,r.SCOPE2A=-1*i.subbalances.scopes.scope_2.assets,r.SCOPE2B=-1*i.subbalances.scopes.scope_2.balance,n.labels.push("Scope 2"),n.datasets[0].data.push(i.subbalances.scopes.scope_2.liabilities*d),n.datasets[0].backgroundColor.push("#D5E8D4"),c+=i.subbalances.scopes.scope_2.liabilities),void 0!==i.subbalances.scopes.scope_3&&(r.SCOPE3=i.subbalances.scopes.scope_3.liabilities,r.SCOPE3A=-1*i.subbalances.scopes.scope_3.assets,r.SCOPE3B=-1*i.subbalances.scopes.scope_3.balance,n.labels.push("Scope 3"),n.datasets[0].data.push(i.subbalances.scopes.scope_3.liabilities*d),n.datasets[0].backgroundColor.push("#9AC7BF"),c+=i.subbalances.scopes.scope_3.liabilities);let b=0;for(const[e,s]of Object.entries(r)){let a=s/d;a>b&&(b=a),r[e]=window.app.formatGrams(a,b)}let u="<p>Total emissions by reporting entity are <strong>"+window.app.formatGrams(i.presafings+i.liabilities,o)+'</strong> <span class="text-muted">(Pre Safing Upstream+ Emitted)</span> with a balance of <strong>'+window.app.formatGrams(-1*t.VER+i.liabilities,o)+"</strong> after compensation/offset.</p>";u+='<h5>Pre Safings: <strong style="color:#BAA743">-'+window.app.formatGrams(i.presafings,o)+"</strong></h5><p>Indirectly avoided upstream Greenhouse Gas emission by choosing an alternative product/variation. </p>",void 0!==i.subbalances.scopes.scope_1&&(u+='<h5>Scope 1: <strong style="color:#A3A3A3">'+r.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!==i.subbalances.scopes.scope_2&&(u+='<h5>Scope 2: <strong style="color:#B4C4B3">'+r.SCOPE2+"</strong></h5><p>Upstream indirect Greenhouse Gas emissions from consumption of purchased electricity, heat, cooling or steam.</p>"),void 0!==i.subbalances.scopes.scope_3&&(u+='<h5>Scope 3: <strong style="color:#7CA19A">'+r.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>"),u+='<h5>Downstream Liability: <strong style="color:#ADC9A9">'+window.app.formatGrams(i.liabilities,o)+"</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>",u+='<h5>Voluntary Emission Reduction: <strong style="color:#437510">-'+window.app.formatGrams(t.VER,o)+"</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).",u+=" In addition, the same amount (additional offset: "+window.app.formatGrams(t.VER,o)+") was used to support reforestation projects under a Long-Short-Term Carbon Cycle Conversation.</p>",$("#prosa").html(u),$("#consensusSVG").html(window.app.parseMustache(window.datasvg,r)),isFinite(-1*p)&&$(".neutralUntil").html(new Date($(".allHighTime").attr("data")-Math.round(31536e6*p)).toLocaleString());const h={type:"doughnut",data:n,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/i.liabilities*100)+"%)"}},datalabels:{formatter:function(e,s){return 0!==c?s.chart.data.labels[s.dataIndex]+":\n"+window.app.formatGrams(e,o)+" ("+Math.round(e/c*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"),h)}catch(e){console.log(e)}}}));let s=await window.co2accounting.createViewAccount();$("#shareLink").val("https://co2offset.io/app/share.html?a="+s.view);const a=function(){navigator.clipboard.writeText("https://co2offset.io/app/share.html?a="+s.view),$("#copyClipboard").tooltip("show"),setTimeout((function(){$("#copyClipboard").tooltip("hide")}),2e3)};$("#copyClipboard").click(a),$("#shareLink").click(a)};