Add better support for hashed pet names on bulk modeler #2

Closed
dice wants to merge 1 commit from dice:enhance-hashed-pets into main
2 changed files with 8 additions and 1 deletions

View file

@ -66,6 +66,10 @@ var DEBUG = document.location.search.substr(0, 6) == "?debug";
} }
function petThumbnailUrl(pet_name) { 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"; return "https://pets.neopets.com/cpn/" + pet_name + "/1/1.png";
} }

View file

@ -68,6 +68,9 @@
%script#bulk-pets-submission-template{:type => 'text/x-jquery/tmpl'} %script#bulk-pets-submission-template{:type => 'text/x-jquery/tmpl'}
%li.waiting %li.waiting
- 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'} %img{:src => 'https://pets.neopets.com/cpn/${pet_name}/1/1.png'}
Review

Ohhh ok so, this section is a bit tricky, because the templating here isn't actually HAML, it's jquery/tmpl. The ${} stuff isn't expanded at HTML generation time, it's included in the HTML and then the JS uses that as a template later.

Probably what we'll need is like, to refactor this template to use the value returned by that petThumbnailUrl function. Haven't dug into this yet but that would be my guess!

Ohhh ok so, this section is a bit tricky, because the templating here isn't actually HAML, it's `jquery/tmpl`. The `${}` stuff isn't expanded at HTML generation time, it's included in the HTML and then the JS uses that as a template later. Probably what we'll need is like, to refactor this _template_ to use the value returned by that `petThumbnailUrl` function. Haven't dug into this yet but that would be my guess!
%span.name ${pet_name} %span.name ${pet_name}
%span.waiting-message= t '.bulk_pets.waiting' %span.waiting-message= t '.bulk_pets.waiting'