Skip to content

Instantly share code, notes, and snippets.

@alissoncs
Created May 9, 2020 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alissoncs/6959e8ca110cbf987975236bbd9ff5e5 to your computer and use it in GitHub Desktop.
Save alissoncs/6959e8ca110cbf987975236bbd9ff5e5 to your computer and use it in GitHub Desktop.
main.js
window.onload = function () {
Application.listAllAwards(function (awards) {
console.log(awards);
document.getElementById('awards-list').innerHTML = '';
for (var i in awards) {
var award = awards[i];
var div = document.createElement('div');
div.id = 'award-' + award.id;
var text = 'Name: ' + award.name + ', Price: $' + award.price;
div.appendChild(document.createTextNode(text));
var button = document.createElement('button');
button.innerHTML = 'Buy Tickets';
button.id = 'award-' + award.id + '-button';
button.addEventListener('click', function (award, button) {
button.innerHTML = 'Checking...';
Application.BuyTicket(awards[i].id, function () {
button.innerHTML = 'Added';
addAwardToCart(award);
});
}.bind(null, award, button));
div.appendChild(button);
document.getElementById('awards-list').appendChild(div);
}
}, function () {
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment