2013-02-01 13:11:14 +01:00

23 lines
773 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// REDEEMING /////////////////////////////////////////////////////////
window.handleRedeemResponse = function(data, textStatus, jqXHR) {
if(data.error) {
alert('Couldnt redeem code. It may be used up, invalid or you have redeemed it already. (Code: '+data.error+')');
return;
}
var text = 'Success! However, pretty display is not implemented.\nMaybe you can make sense of the following:\n';
alert(text + JSON.stringify(data));
}
window.setupRedeem = function() {
$("#redeem").keypress(function(e) {
if((e.keyCode ? e.keyCode : e.which) != 13) return;
var data = {passcode: $(this).val()};
window.postAjax('redeemReward', data, window.handleRedeemResponse,
function() { alert('HTTP request failed. Maybe try again?'); });
});
}