document.addEventListener("DOMContentLoaded", function () { const factors = { glass: { gram: 0.762, kg: 762 }, paper: { gram: 3.891, kg: 3891 }, cardboard: { gram: 3.439, kg: 3439 }, steel: { gram: 2.36, kg: 2360 }, aluminium: { gram: 19.34, kg: 19340 }, plastic: { gram: 2.324, kg: 2324 }, wood: { gram: 2.712, kg: 2712 }, paint: { gram: 2.84, kg: 2840 }, cloth: { gram: 7.869, kg: 7869 }, rubber: { gram: 5.891, kg: 5891 } }; const calculateBtn = document.getElementById("ep-calculate"); if (!calculateBtn) return; calculateBtn.addEventListener("click", function () { const material = document.getElementById("ep-material").value; const weight = parseFloat(document.getElementById("ep-weight").value); const unit = document.getElementById("ep-unit").value; const qty = parseInt(document.getElementById("ep-qty").value); if (!material) { alert("Please select a material."); return; } if (isNaN(weight) || weight <= 0) { alert("Please enter a valid weight."); return; } if (isNaN(qty) || qty <= 0) { alert("Please enter a valid quantity."); return; } const factor = factors[material][unit]; // CO₂ calculation const co2 = weight * factor * qty; // Carbon Impact (kg CO₂e) const carbonImpact = co2 / 1000; // Eco Points (1 point per 10g CO₂ saved example) const ecoPoints = Math.round(co2 / 10); // Display Results document.getElementById("ep-co2").innerHTML = co2.toLocaleString(undefined, {maximumFractionDigits:2}) + " g CO₂e"; document.getElementById("ep-impact").innerHTML = carbonImpact.toFixed(2) + " kg CO₂e"; document.getElementById("ep-points").innerHTML = ecoPoints.toLocaleString(); document.getElementById("ep-result").style.display = "block"; // Smooth scroll to result document.getElementById("ep-result").scrollIntoView({ behavior: "smooth", block: "start" }); }); });

Main Menu

🌍 Eco Impact Calculator

Calculate your product's environmental impact.

CO₂:
Carbon Impact:
Eco Points:

🌱 Great Choice! Your product contributes towards a greener future.

Become an EarthPixl Vendor