Created
May 9, 2020 19:01
-
-
Save alissoncs/6959e8ca110cbf987975236bbd9ff5e5 to your computer and use it in GitHub Desktop.
main.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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