From e80a49a0861a122b24d6dd953926307c9d6f3ccc Mon Sep 17 00:00:00 2001 From: Steve C Date: Fri, 30 Aug 2024 01:45:39 -0400 Subject: [PATCH] Add better support for hashed pet names --- app/assets/javascripts/pets/bulk.js | 4 ++++ app/views/pets/bulk.html.haml | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/pets/bulk.js b/app/assets/javascripts/pets/bulk.js index 44f69c97..0df5b56e 100644 --- a/app/assets/javascripts/pets/bulk.js +++ b/app/assets/javascripts/pets/bulk.js @@ -66,6 +66,10 @@ var DEBUG = document.location.search.substr(0, 6) == "?debug"; } function petThumbnailUrl(pet_name) { + if (pet_name[0] == "@") { + // if first character is "@", use the hash url + return "https://pets.neopets.com/cp/" + pet_name.substr(1) + "/1/1.png"; + } return "https://pets.neopets.com/cpn/" + pet_name + "/1/1.png"; } diff --git a/app/views/pets/bulk.html.haml b/app/views/pets/bulk.html.haml index 44d7a0aa..4dba2f6c 100644 --- a/app/views/pets/bulk.html.haml +++ b/app/views/pets/bulk.html.haml @@ -68,7 +68,10 @@ %script#bulk-pets-submission-template{:type => 'text/x-jquery/tmpl'} %li.waiting - %img{:src => 'https://pets.neopets.com/cpn/${pet_name}/1/1.png'} + - if pet_name.starts_with?('@') + %img{:src => 'https://pets.neopets.com/cp/${pet_name[1..-1]}/1/1.png'} + - else + %img{:src => 'https://pets.neopets.com/cpn/${pet_name}/1/1.png'} %span.name ${pet_name} %span.waiting-message= t '.bulk_pets.waiting' %span.loading-message= t '.bulk_pets.loading'