diff --git a/app/assets/javascripts/pets/bulk.js b/app/assets/javascripts/pets/bulk.js index 44f69c97..265ab232 100644 --- a/app/assets/javascripts/pets/bulk.js +++ b/app/assets/javascripts/pets/bulk.js @@ -1,5 +1,14 @@ var DEBUG = document.location.search.substr(0, 6) == "?debug"; +function petThumbnailUrl(pet_name) { + // if first character is "@", use the hash url + if (pet_name[0] == "@") { + return "https://pets.neopets.com/cp/" + pet_name.substr(1) + "/1/1.png"; + } + + return "https://pets.neopets.com/cpn/" + pet_name + "/1/1.png"; +} + /* Needed items form */ (function () { var UI = {}; @@ -65,10 +74,6 @@ var DEBUG = document.location.search.substr(0, 6) == "?debug"; loadItems(data.query); } - function petThumbnailUrl(pet_name) { - return "https://pets.neopets.com/cpn/" + pet_name + "/1/1.png"; - } - /* Items */ function loadItems(query) { @@ -127,7 +132,7 @@ var DEBUG = document.location.search.substr(0, 6) == "?debug"; function Pet(name) { var el = $("#bulk-pets-submission-template") - .tmpl({ pet_name: name }) + .tmpl({ pet_name: name, pet_thumbnail: petThumbnailUrl(name) }) .appendTo(queue_el); this.load = function () { diff --git a/app/views/pets/bulk.html.haml b/app/views/pets/bulk.html.haml index 44d7a0aa..a2d0e5fa 100644 --- a/app/views/pets/bulk.html.haml +++ b/app/views/pets/bulk.html.haml @@ -68,7 +68,7 @@ %script#bulk-pets-submission-template{:type => 'text/x-jquery/tmpl'} %li.waiting - %img{:src => 'https://pets.neopets.com/cpn/${pet_name}/1/1.png'} + %img{:src => '${pet_thumbnail}'} %span.name ${pet_name} %span.waiting-message= t '.bulk_pets.waiting' %span.loading-message= t '.bulk_pets.loading'