From a375707e406d0a8b13707934cf4df26bf00e5326 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 4 Apr 2014 15:53:53 -0500 Subject: [PATCH] handle errors from neopia, finally! --- app/assets/javascripts/outfits/new.js | 12 ++++++++++++ app/assets/stylesheets/outfits/_new.sass | 3 +++ app/views/outfits/new.html.haml | 3 +++ config/locales/en.yml | 1 + 4 files changed, 19 insertions(+) diff --git a/app/assets/javascripts/outfits/new.js b/app/assets/javascripts/outfits/new.js index 968b25be..46bd7b33 100644 --- a/app/assets/javascripts/outfits/new.js +++ b/app/assets/javascripts/outfits/new.js @@ -224,6 +224,18 @@ $(function () { el.fadeIn('medium'); addDisqusCount(); }); + + var neopiaError = document.location.search.match(/neopia%5Berror%5D=([^&]+)/); + if (neopiaError !== null) { + var message = decodeURI(neopiaError[1]).replace(/\+/g, ' '); + if (message === "pet not found") { + $('#pet-not-found').show(); + } else { + var el = $('#neopia-error'); + var text = el.text().replace('%{message}', message); + el.text(text).show(); + } + } }); function addDisqusCount() { diff --git a/app/assets/stylesheets/outfits/_new.sass b/app/assets/stylesheets/outfits/_new.sass index f33f7e3f..09442ffd 100644 --- a/app/assets/stylesheets/outfits/_new.sass +++ b/app/assets/stylesheets/outfits/_new.sass @@ -3,6 +3,9 @@ body.outfits-new +campaign-progress + #pet-not-found, #neopia-error + display: none + #outfit-forms +clearfix +module diff --git a/app/views/outfits/new.html.haml b/app/views/outfits/new.html.haml index d0b3b2c8..7e364e25 100644 --- a/app/views/outfits/new.html.haml +++ b/app/views/outfits/new.html.haml @@ -2,6 +2,9 @@ = campaign_progress +%p#pet-not-found.alert= t 'pets.load.not_found' +%p#neopia-error.alert= t 'pets.load.neopia_error' + #outfit-forms - localized_cache :action_suffix => 'outfit_forms_intro' do #pet-preview diff --git a/config/locales/en.yml b/config/locales/en.yml index 21e6b3a7..9b946c9b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -801,6 +801,7 @@ en: pet_download_error: We couldn't connect to Neopets to look up the pet. Maybe they're down. Please try again later! + neopia_error: "We couldn't load that pet: \"%{message}\". Try again later?" users: index: