let goalNode = document.getElementById('donationgoal');
let nameText = document.getElementById('name');
let rangeText = document.getElementById('range');
let progressFrom = document.getElementById('from');
let progressTo = document.getElementById('to');

window.addEventListener('message', function (event) {
    let message = event.detail;
    let data = message.data;

    let percent = ((data.value / data.goal) * 100);
    if (percent > 100) {percent = 100;}

    nameText.textContent = data.title;
    progressFrom.textContent = data.value;
    progressTo.textContent = data.goal;
    goalNode.style.setProperty('--progress', `${percent}%`);
});
