From 909c760061504a3b576bdc122ccdc78b86adbd90 Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Sat, 27 Apr 2013 22:37:21 -0500 Subject: [PATCH] * New passcode redemption plaintext format using Unicode chars * Don't use digit format for plaintext redemption * Remove unneecessary 'return true' statements * Passcode guessing doesn't dirty up the results window as much * Add asterisks to names for all types of guess --- code/redeeming.js | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/code/redeeming.js b/code/redeeming.js index eb2020c2..1c4931de 100644 --- a/code/redeeming.js +++ b/code/redeeming.js @@ -55,7 +55,7 @@ window.REDEEM_HANDLERS = { var suffix = ''; return { table: '' + prefix + 'L' + level + suffix + '' + acquired.name.long + ' [' + acquired.count + ']', - html: acquired.count + '@' + acquired.name.short + prefix + level + suffix, + html: acquired.count + '×' + acquired.name.short + prefix + level + suffix, plain: acquired.count + '@' + acquired.name.short + level }; } @@ -68,7 +68,7 @@ window.REDEEM_HANDLERS = { var abbreviation = rarity.split('_').map(function (i) {return i[0];}).join(''); return { table: '' + prefix + abbreviation + suffix + '' + acquired.name.long + ' [' + acquired.count + ']', - html: acquired.count + '@' + prefix + abbreviation + suffix, + html: acquired.count + '×' + prefix + abbreviation + suffix, plain: acquired.count + '@' + abbreviation }; } @@ -78,7 +78,7 @@ window.REDEEM_HANDLERS = { format: function(acquired, group) { return { table: '+' + acquired.name.long + ' [' + acquired.count + ']', - html: acquired.count + '@' + acquired.name.short, + html: acquired.count + '×' + acquired.name.short, plain: acquired.count + '@' + acquired.name.short }; } @@ -134,7 +134,6 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { }; return false; } - return true; }); // Fall back to the default handler if necessary @@ -148,15 +147,16 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { // Collect the data that we know type = resource.resourceType; key = handler.functions.decode(type, resource); - name = window.REDEEM_RESOURCES[type] || {long: type + '*', short: type[0] + '*'}; + name = window.REDEEM_RESOURCES[type] || {long: type, short: type[0]}; // Decide if we inferred this resource if(!(type in window.REDEEM_RESOURCES) || handler.taxonomy !== handler.processed_as) { + name.long += '*'; + name.short += '*'; inferred.push({type: type, key: key, handler: handler}); } return false; } - return true; }); // Update frequencies @@ -169,15 +169,13 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { payload[type][key].count += 1; }); - // Get AP, XM, and other static quantities + // Get AP and XM. $.each([{label: 'AP', award: parseInt(data.result.apAward)}, {label: 'XM', award: parseInt(data.result.xmAward)}], function(idx, val) { if(val.award > 0) { - var formatted = digits(val.award) + ' ' + val.label; - results.table.push('+' + formatted + ''); - results.html.push(formatted); - results.plain.push(formatted); + results.table.push('+' + digits(val.award) + ' ' + val.label + ''); + results.html.push(val.award + ' ' + val.label); + results.plain.push(val.award + ' ' + val.label); } - return true; }); // Build the formatted results alphabetically @@ -186,32 +184,28 @@ window.handleRedeemResponse = function(data, textStatus, jqXHR) { var acquired = payload[type][key]; $.each(acquired.handler.functions.format(acquired, key), function(format, string) { results[format].push(string); - return true; }); - return true; }); - return true; }); + // Let the user know if we had to guess if (inferred.length > 0) { - results.table.push('**IITC had to guess!'); - results.table.push('**Submit a log including:'); + results.table.push('*Guessed (check console)'); $.each(inferred, function (idx, val) { - var type = val.type + ':' + val.key, taxonomy = val.handler.taxonomy + (val.handler.taxonomy === val.handler.processed_as ? '' : ' =~ ' + val.handler.processed_as); - results.table.push('!' + type + ''); - results.table.push('!' + taxonomy + ''); - console.log(passcode + ' => [INFERRED] ' + type + ' :: ' + taxonomy); + console.log(passcode + + ' => [INFERRED] ' + val.type + ':' + val.key + ' :: ' + + val.handler.taxonomy + ' =~ ' + val.handler.processed_as); }); } // Add table footers - results.table.push('>>>' + encouragement + '
' + results.html.join('/') + '') + '\', true);" style="font-family: monospace;">[plaintext]
'); // Display formatted versions in a table, plaintext, and the console log to_alert = '' + results.table.map(function(a) {return '' + a + '';}).join("\n") + '
'; - to_log = results.plain.join('/'); + to_log = '[SUCCESS] ' + results.plain.join('/'); } alert(to_alert, true);