From 5cd3b006daeef4af0e0bfdd96c5db2473259dbfe Mon Sep 17 00:00:00 2001 From: Stefan Breunig Date: Fri, 8 Feb 2013 03:03:40 +0100 Subject: [PATCH] update build, dump version, add news file --- NEWS.md | 19 ++++++++++++++ main.js | 2 +- total-conversion-build.user.js | 48 ++++++++++++++++++++++++++++------ 3 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 NEWS.md diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 00000000..8c8b8f99 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,19 @@ +CHANGES IN 0.3 +============== + +- Feature: more info for shields in tooltip (by JasonMillward) +- Feature: pretty display for redeemed codes (by integ3r) +- Change: Portal details are now scrollable when height is too small +- Change: explain the meaning of the links display in tooltip +- Bugfix: appear less greedy in Chrome when asking permission (by epf) +- Bugfix: Geosearch broken for non-ASCII chars +- Bugfix: fix spelling of Niantic (by Bananeweizen) +- Bugfix: fix spelling in README (by epf) +- Bugfix: report portal displayed wrong longitude +- Bugfix: timestamps in chat were displaying seconds instead of minutes +- Bugfix: level/ap calculations for level 8 players + +If your version appears broken, please update before reporting an issue. +Also clean your cache, this can usually be done with ctrl + shift + +clicking the reload button. If your problem persists, please open a new +issue. diff --git a/main.js b/main.js index b0528a35..6c999dda 100644 --- a/main.js +++ b/main.js @@ -1,7 +1,7 @@ // ==UserScript== // @id ingress-intel-total-conversion@breunigs // @name intel map total conversion -// @version 0.2-@@BUILDDATE@@ +// @version 0.3-@@BUILDDATE@@ // @namespace https://github.com/breunigs/ingress-intel-total-conversion // @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js // @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js diff --git a/total-conversion-build.user.js b/total-conversion-build.user.js index ab8e5789..ef2c7391 100644 --- a/total-conversion-build.user.js +++ b/total-conversion-build.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @id ingress-intel-total-conversion@breunigs // @name intel map total conversion -// @version 0.2-2013-02-08-024305 +// @version 0.3-2013-02-08-030330 // @namespace https://github.com/breunigs/ingress-intel-total-conversion // @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js // @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js @@ -2018,13 +2018,45 @@ window.unselectOldPortal = function() { // REDEEMING ///////////////////////////////////////////////////////// window.handleRedeemResponse = function(data, textStatus, jqXHR) { - if(data.error) { - alert('Couldn’t redeem code. It may be used up, invalid or you have redeemed it already. (Code: '+data.error+')'); - return; - } + if (data.error) { + var error = ''; + if (data.error === 'ALREADY_REDEEMED') { + error = 'The passcode has already been redeemed.'; + } else if (data.error === 'ALREADY_REDEEMED_BY_PLAYER') { + error = 'You have already redeemed this passcode.'; + } else if (data.error === 'INVALID_PASSCODE') { + error = 'This passcode is invalid.'; + } else { + error = 'The passcode cannot be redeemed.'; + } + alert("Error: " + data.error + "\n" + error); + } else if (data.result) { + var res_level = 0, res_count = 0; + var xmp_level = 0, xmp_count = 0; + var shield_rarity = '', shield_count = 0; - var text = 'Success! However, pretty display is not implemented.\nMaybe you can make sense of the following:\n'; - alert(text + JSON.stringify(data)); + // This assumes that each passcode gives only one type of resonator/XMP/shield. + // This may break at some point, depending on changes to passcode functionality. + for (var i in data.result.inventoryAward) { + var acquired = data.result.inventoryAward[i][2]; + if (acquired.modResource) { + if (acquired.modResource.resourceType === 'RES_SHIELD') { + shield_rarity = acquired.modResource.rarity.split('_').map(function (i) {return i[0]}).join(''); + shield_count++; + } + } else if (acquired.resourceWithLevels) { + if (acquired.resourceWithLevels.resourceType === 'EMITTER_A') { + res_level = acquired.resourceWithLevels.level; + res_count++; + } else if (acquired.resourceWithLevels.resourceType === 'EMP_BURSTER') { + xmp_level = acquired.resourceWithLevels.level; + xmp_count++; + } + } + } + + alert("Passcode redeemed!\n" + [data.result.apAward + 'AP', data.result.xmAward + 'XM', res_count + 'xL' + res_level + ' RES', xmp_count + 'xL' + xmp_level + ' XMP', shield_count + 'x' + shield_rarity + ' SHIELD'].join('/')); + } } window.setupRedeem = function() { @@ -2032,7 +2064,7 @@ window.setupRedeem = function() { 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?'); }); + function() { alert('HTTP request failed. Try again?'); }); }); }