[core] passcode contents are displayed correctly
Includes some other small fixes regarding passcodes. Fixes #883
This commit is contained in:
parent
2ec481b673
commit
c4117b3c29
@ -389,6 +389,9 @@ window.setupPlayerStat = function() {
|
||||
var level = PLAYER.verified_level;
|
||||
PLAYER.level = level; //for historical reasons IITC expects PLAYER.level to contain the current player level
|
||||
|
||||
var n = window.PLAYER.nickname;
|
||||
PLAYER.nickMatcher = new RegExp('\\b('+n+')\\b', 'ig');
|
||||
|
||||
var ap = parseInt(PLAYER.ap);
|
||||
var thisLvlAp = parseInt(PLAYER.min_ap_for_current_level);
|
||||
var nextLvlAp = parseInt(PLAYER.min_ap_for_next_level);
|
||||
@ -601,10 +604,6 @@ function boot() {
|
||||
}
|
||||
urlPortal = getURLParam('pguid');
|
||||
|
||||
// load only once
|
||||
var n = window.PLAYER['nickname'];
|
||||
window.PLAYER['nickMatcher'] = new RegExp('\\b('+n+')\\b', 'ig');
|
||||
|
||||
$('#sidebar').show();
|
||||
|
||||
if(window.bootPlugins) {
|
||||
|
@ -1,8 +1,6 @@
|
||||
// REDEEMING ///////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO remove lots of unused code from the old redeeming method
|
||||
|
||||
window.REDEEM_SHORT_NAMES = {
|
||||
'portal shield':'S',
|
||||
'force amp':'FA',
|
||||
@ -27,15 +25,29 @@ window.REDEEM_STATUSES = {
|
||||
};
|
||||
|
||||
window.handleRedeemResponse = function(data, textStatus, jqXHR) {
|
||||
var passcode = this.passcode;
|
||||
var passcode = jqXHR.passcode;
|
||||
|
||||
if(data.error) {
|
||||
console.error('Error redeeming passcode "'+passcode+'": ' + data.error)
|
||||
dialog({
|
||||
title: 'Error: ' + passcode,
|
||||
html: '<strong>' + data.error + '</strong>'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(!data.rewards) {
|
||||
console.error('Error redeeming passcode "'+passcode+'": ', data)
|
||||
dialog({
|
||||
title: 'Error: ' + passcode,
|
||||
html: '<strong>An unexpected error occured</strong>'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if(data.playerData) {
|
||||
window.PLAYER = data.playerData;
|
||||
window.setupPlayerStat();
|
||||
}
|
||||
|
||||
var format = "long";
|
||||
try {
|
||||
@ -49,9 +61,8 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) {
|
||||
if(!formatHandlers[format])
|
||||
format = "long";
|
||||
|
||||
var html = formatHandlers[format](data);
|
||||
var html = formatHandlers[format](data.rewards);
|
||||
|
||||
var that = this;
|
||||
var buttons = {};
|
||||
Object.keys(formatHandlers).forEach(function(label) {
|
||||
if(label == format) return;
|
||||
@ -59,7 +70,7 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) {
|
||||
buttons[label.toUpperCase()] = function() {
|
||||
$(this).dialog("close");
|
||||
localStorage["iitc-passcode-format"] = label;
|
||||
handleRedeemResponse.call(that, data, textStatus, jqXHR);
|
||||
handleRedeemResponse(data, textStatus, jqXHR);
|
||||
}
|
||||
});
|
||||
|
||||
@ -154,11 +165,12 @@ window.formatPasscodeShort = function(data) {
|
||||
|
||||
window.setupRedeem = function() {
|
||||
$("#redeem").keypress(function(e) {
|
||||
if((e.keyCode ? e.keyCode : e.which) !== 13 || !$(this).val()) return;
|
||||
var data = {passcode: $(this).val()};
|
||||
if((e.keyCode ? e.keyCode : e.which) !== 13) return;
|
||||
|
||||
window.postAjax('redeemReward', data, window.handleRedeemResponse,
|
||||
function(response) {
|
||||
var passcode = $(this).val();
|
||||
if(!passcode) return;
|
||||
|
||||
var jqXHR = window.postAjax('redeemReward', {passcode:passcode}, window.handleRedeemResponse, function(response) {
|
||||
var extra = '';
|
||||
if(response.status) {
|
||||
extra = (window.REDEEM_STATUSES[response.status] || 'The server indicated an error.') + ' (HTTP ' + response.status + ')';
|
||||
@ -170,5 +182,6 @@ window.setupRedeem = function() {
|
||||
html: '<strong>The HTTP request failed.</strong> ' + extra
|
||||
});
|
||||
});
|
||||
jqXHR.passcode = passcode;
|
||||
});
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user