1
0
Fork 0
forked from OpenNeo/impress

Merge pet_query.js into its only call site

This commit is contained in:
Emi Matchu 2024-02-18 20:31:21 -08:00
parent 496b517e74
commit 0d23412fba
3 changed files with 25 additions and 24 deletions

View file

@ -1,5 +1,28 @@
(function () {
// don't need to export anything in here
function petImage(id, size) {
return "https://pets.neopets.com/" + id + "/1/" + size + ".png";
}
var PetQuery = {},
query_string = document.location.hash || document.location.search;
$.each(query_string.substr(1).split("&"), function () {
var split_piece = this.split("=");
if (split_piece.length == 2) {
PetQuery[split_piece[0]] = split_piece[1];
}
});
if (PetQuery.name) {
if (PetQuery.species && PetQuery.color) {
$("#pet-query-notice-template")
.tmpl({
pet_name: PetQuery.name,
pet_image_url: petImage("cpn/" + PetQuery.name, 1),
})
.prependTo("#container");
}
}
var preview_el = $("#pet-preview"),
img_el = preview_el.find("img"),

View file

@ -1,22 +0,0 @@
function petImage(id, size) {
return 'https://pets.neopets.com/' + id + '/1/' + size + '.png';
}
var PetQuery = {},
query_string = document.location.hash || document.location.search;
$.each(query_string.substr(1).split('&'), function () {
var split_piece = this.split('=');
if(split_piece.length == 2) {
PetQuery[split_piece[0]] = split_piece[1];
}
});
if(PetQuery.name) {
if(PetQuery.species && PetQuery.color) {
$('#pet-query-notice-template').tmpl({
pet_name: PetQuery.name,
pet_image_url: petImage('cpn/' + PetQuery.name, 1)
}).prependTo('#container');
}
}

View file

@ -117,4 +117,4 @@
- content_for :javascripts do
= include_javascript_libraries :jquery20, :jquery_tmpl
= javascript_include_tag 'ajax_auth', 'react', 'jquery.timeago', 'pet_query', 'outfits/new'
= javascript_include_tag 'ajax_auth', 'react', 'jquery.timeago', 'outfits/new'