forked from OpenNeo/impress
Remove needed items form on Modeling Hub
I think this has just been broken for a long time? And I don't think it's very useful in a world 15 years later, where our problem *used* to be giant gaps in our library, which isn't really our data problem anymore.
This commit is contained in:
parent
a315282b70
commit
a14c4fca48
12 changed files with 59 additions and 344 deletions
|
@ -1,116 +1,5 @@
|
|||
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 = {};
|
||||
UI.form = $("#needed-items-form");
|
||||
UI.alert = $("#needed-items-alert");
|
||||
UI.pet_name_field = $("#needed-items-pet-name-field");
|
||||
UI.pet_thumbnail = $("#needed-items-pet-thumbnail");
|
||||
UI.pet_header = $("#needed-items-pet-header");
|
||||
UI.reload = $("#needed-items-reload");
|
||||
UI.pet_items = $("#needed-items-pet-items");
|
||||
UI.item_template = $("#item-template");
|
||||
|
||||
var current_request = { abort: function () {} };
|
||||
function sendRequest(options) {
|
||||
current_request = $.ajax(options);
|
||||
}
|
||||
|
||||
function cancelRequest() {
|
||||
if (DEBUG) console.log("Canceling request", current_request);
|
||||
current_request.abort();
|
||||
}
|
||||
|
||||
/* Pet */
|
||||
|
||||
var last_successful_pet_name = null;
|
||||
|
||||
function loadPet(pet_name) {
|
||||
// If there is a request in progress, kill it. Our new pet request takes
|
||||
// priority, and, if I submit a name while the previous name is loading, I
|
||||
// don't want to process both responses.
|
||||
cancelRequest();
|
||||
|
||||
sendRequest({
|
||||
url: UI.form.attr("action") + ".json",
|
||||
dataType: "json",
|
||||
data: { name: pet_name },
|
||||
error: petError,
|
||||
success: function (data) {
|
||||
petSuccess(data, pet_name);
|
||||
},
|
||||
complete: petComplete,
|
||||
});
|
||||
|
||||
UI.form.removeClass("failed").addClass("loading-pet");
|
||||
}
|
||||
|
||||
function petComplete() {
|
||||
UI.form.removeClass("loading-pet");
|
||||
}
|
||||
|
||||
function petError(xhr) {
|
||||
UI.alert.text(xhr.responseText);
|
||||
UI.form.addClass("failed");
|
||||
}
|
||||
|
||||
function petSuccess(data, pet_name) {
|
||||
last_successful_pet_name = pet_name;
|
||||
UI.pet_thumbnail.attr("src", petThumbnailUrl(pet_name));
|
||||
UI.pet_header.empty();
|
||||
$("#needed-items-pet-header-template")
|
||||
.tmpl({ pet_name: pet_name })
|
||||
.appendTo(UI.pet_header);
|
||||
loadItems(data.query);
|
||||
}
|
||||
|
||||
/* Items */
|
||||
|
||||
function loadItems(query) {
|
||||
UI.form.addClass("loading-items");
|
||||
sendRequest({
|
||||
url: "/items/needed.json",
|
||||
dataType: "json",
|
||||
data: query,
|
||||
success: itemsSuccess,
|
||||
});
|
||||
}
|
||||
|
||||
function itemsSuccess(items) {
|
||||
if (DEBUG) {
|
||||
// The dev server is missing lots of data, so sends me 2000+ needed
|
||||
// items. We don't need that many for styling, so limit it to 100 to make
|
||||
// my browser happier.
|
||||
items = items.slice(0, 100);
|
||||
}
|
||||
|
||||
UI.pet_items.empty();
|
||||
UI.item_template.tmpl(items).appendTo(UI.pet_items);
|
||||
|
||||
UI.form.removeClass("loading-items").addClass("loaded");
|
||||
}
|
||||
|
||||
UI.form.submit(function (e) {
|
||||
e.preventDefault();
|
||||
loadPet(UI.pet_name_field.val());
|
||||
});
|
||||
|
||||
UI.reload.click(function (e) {
|
||||
e.preventDefault();
|
||||
loadPet(last_successful_pet_name);
|
||||
});
|
||||
})();
|
||||
|
||||
/* Bulk pets form */
|
||||
(function () {
|
||||
var form = $("#bulk-pets-form"),
|
||||
|
@ -122,6 +11,15 @@ function petThumbnailUrl(pet_name) {
|
|||
|
||||
$(document.body).addClass("js");
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
bulk_load_queue = new (function BulkLoadQueue() {
|
||||
var RECENTLY_SENT_INTERVAL_IN_SECONDS = 30;
|
||||
var RECENTLY_SENT_MAX = 3;
|
||||
|
|
|
@ -2,70 +2,8 @@
|
|||
@import "../partials/clean/mixins"
|
||||
|
||||
body.pets-bulk
|
||||
#needed-items-form, #bulk-pets-form
|
||||
text-align: center
|
||||
|
||||
#needed-items-form
|
||||
#needed-items-pet
|
||||
border-top: 1px solid $soft-border-color
|
||||
display: none
|
||||
margin-top: 1em
|
||||
padding-top: 1em
|
||||
|
||||
h4
|
||||
font-size: 150%
|
||||
margin-bottom: .5em
|
||||
|
||||
#needed-items-reload
|
||||
+inline-block
|
||||
font-size: 12px
|
||||
margin-left: 1em
|
||||
vertical-align: middle
|
||||
|
||||
#needed-items-alert
|
||||
display: none
|
||||
margin-top: .5em
|
||||
|
||||
#needed-items-pet-thumbnail
|
||||
height: 50px
|
||||
width: 50px
|
||||
|
||||
#needed-items-pet-items
|
||||
li.owned
|
||||
background: $module-bg-color
|
||||
border: 1px solid $module-border-color
|
||||
|
||||
.object-owned
|
||||
color: $soft-text-color
|
||||
display: block
|
||||
font-size: 75%
|
||||
font-style: italic
|
||||
padding-bottom: .25em
|
||||
|
||||
&.loading-pet, &.loading-items
|
||||
#needed-items-pet-name-field
|
||||
background:
|
||||
image: image-url("loading.gif")
|
||||
position: center right
|
||||
repeat: no-repeat
|
||||
|
||||
#needed-items-pet-items
|
||||
+opacity(.50)
|
||||
|
||||
&.loading-pet
|
||||
#needed-items-pet h4
|
||||
+opacity(.50)
|
||||
|
||||
&.loaded
|
||||
#needed-items-pet
|
||||
display: block
|
||||
|
||||
&.failed
|
||||
#needed-items-alert
|
||||
display: block
|
||||
|
||||
#bulk-pets-form
|
||||
border-top: 1px solid $module-border-color
|
||||
text-align: center
|
||||
margin-top: 12px
|
||||
padding-top: 12px
|
||||
|
||||
|
|
|
@ -112,27 +112,6 @@ class ItemsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def needed
|
||||
if params[:color] && params[:species]
|
||||
@pet_type = PetType.find_by_color_id_and_species_id(
|
||||
params[:color],
|
||||
params[:species]
|
||||
)
|
||||
end
|
||||
|
||||
unless @pet_type
|
||||
raise ActiveRecord::RecordNotFound, 'Pet type not found'
|
||||
end
|
||||
|
||||
@items = @pet_type.needed_items.order(:name)
|
||||
assign_closeted!(@items)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { @pet_name = params[:name] ; render :layout => 'application' }
|
||||
format.json { render :json => @items }
|
||||
end
|
||||
end
|
||||
|
||||
def sources
|
||||
# Load all the items, then group them by source.
|
||||
item_ids = params[:ids].split(",")
|
||||
|
|
|
@ -39,7 +39,6 @@ class PetsController < ApplicationController
|
|||
def destination
|
||||
case (params[:destination] || params[:origin])
|
||||
when 'wardrobe' then wardrobe_path
|
||||
when 'needed_items' then needed_items_path
|
||||
else root_path
|
||||
end
|
||||
end
|
||||
|
|
|
@ -79,27 +79,6 @@ class PetType < ApplicationRecord
|
|||
species_human_name: possibly_new_species.human_name)
|
||||
end
|
||||
|
||||
def needed_items
|
||||
# If I need this item on a pet type, that means that we've already seen it
|
||||
# and it's body-specific. So, there's a body-specific asset for the item,
|
||||
# but no asset that fits this pet type.
|
||||
i = Item.arel_table
|
||||
psa = ParentSwfAssetRelationship.arel_table
|
||||
sa = SwfAsset.arel_table
|
||||
|
||||
Item.where('(' + ParentSwfAssetRelationship.select('count(DISTINCT body_id)').joins(:swf_asset).
|
||||
where(
|
||||
psa[:parent_id].eq(i[:id]).and(
|
||||
psa[:parent_type].eq('Item').and(
|
||||
sa[:body_id].not_eq(self.body_id)))
|
||||
).to_sql + ') > 1').
|
||||
where(ParentSwfAssetRelationship.joins(:swf_asset).where(
|
||||
psa[:parent_id].eq(i[:id]).and(
|
||||
psa[:parent_type].eq('Item').and(
|
||||
sa[:body_id].in([self.body_id, 0])))
|
||||
).exists.not)
|
||||
end
|
||||
|
||||
def add_pet_state_from_biology!(biology)
|
||||
pet_state = PetState.from_pet_type_and_biology_info(self, biology)
|
||||
pet_state
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
- title "Needed items for #{@pet_type.human_name}"
|
||||
%h2
|
||||
= image_tag "https://pets.neopets.com/cpn/#{@pet_name}/1/1.png",
|
||||
:class => 'inline-image'
|
||||
%span.pet-name= @pet_name
|
||||
can model…
|
||||
%ul.buttons
|
||||
%li
|
||||
= form_tag load_pet_path do
|
||||
= origin_tag 'needed_items'
|
||||
= hidden_field_tag 'name', @pet_name
|
||||
= submit_tag "I'm wearing one now!", :class => 'loud'
|
||||
%li
|
||||
= link_to 'What do I own?', 'https://www.neopets.com/closet.phtml',
|
||||
:class => 'button', :target => '_blank'
|
||||
= render @items
|
||||
|
||||
- content_for :stylesheets do
|
||||
= page_stylesheet_link_tag "layouts/items"
|
|
@ -1,42 +1,20 @@
|
|||
- title t('modeling_hub')
|
||||
|
||||
= form_tag load_pet_path, :id => 'needed-items-form' do
|
||||
- localized_cache :action_suffix => 'needed_items_content' do
|
||||
%h3= t '.needed_items.header'
|
||||
|
||||
%p= t '.needed_items.explanation'
|
||||
|
||||
= origin_tag bulk_pets_path
|
||||
= destination_tag 'needed_items'
|
||||
|
||||
%input#needed-items-pet-name-field{:type => "text", :name => "name"}/
|
||||
%input{:type => "submit", :value => t('.needed_items.submit')}/
|
||||
|
||||
#needed-items-alert.alert
|
||||
|
||||
#needed-items-pet.script-only
|
||||
%h4
|
||||
%img#needed-items-pet-thumbnail.inline-image
|
||||
%span#needed-items-pet-header
|
||||
%button#needed-items-reload= t '.needed_items.reload'
|
||||
|
||||
%ul#needed-items-pet-items
|
||||
|
||||
= form_tag load_pet_path, :id => 'bulk-pets-form' do
|
||||
- localized_cache :action_suffix => 'bulk_pets_content' do
|
||||
%h3= t '.bulk_pets.header'
|
||||
%h3= t '.header'
|
||||
|
||||
%p= t '.bulk_pets.explanation'
|
||||
%p= t '.explanation'
|
||||
|
||||
= origin_tag bulk_pets_path
|
||||
|
||||
%div.noscript
|
||||
%input{:name => "name", :type => "text"}/
|
||||
%input{:type => "submit", :value => t('.bulk_pets.submit')}/
|
||||
%input{:type => "submit", :value => t('.submit')}/
|
||||
%div.script-only
|
||||
%textarea
|
||||
%button#bulk-pets-form-add{:type => "button"}= t '.bulk_pets.add'
|
||||
%button#bulk-pets-form-clear{:type => "button"}= t '.bulk_pets.clear'
|
||||
%button#bulk-pets-form-add{:type => "button"}= t '.add'
|
||||
%button#bulk-pets-form-clear{:type => "button"}= t '.clear'
|
||||
%ul
|
||||
|
||||
- localized_cache :action_suffix => 'templates' do
|
||||
|
@ -70,12 +48,12 @@
|
|||
%li.waiting
|
||||
%img{:src => '${pet_thumbnail}'}
|
||||
%span.name ${pet_name}
|
||||
%span.waiting-message= t '.bulk_pets.waiting'
|
||||
%span.loading-message= t '.bulk_pets.loading'
|
||||
%span.waiting-message= t '.waiting'
|
||||
%span.loading-message= t '.loading'
|
||||
%span.response
|
||||
|
||||
%script#bulk-pets-submission-success-template{:type => 'text/x-jquery/tmpl'}
|
||||
= t '.bulk_pets.submission_success', :points => '${points}'
|
||||
= t '.submission_success', :points => '${points}'
|
||||
|
||||
- content_for :javascripts do
|
||||
= include_javascript_libraries :jquery, :jquery_tmpl
|
||||
|
|
|
@ -630,16 +630,6 @@ en-MEEP:
|
|||
|
||||
pets:
|
||||
bulk:
|
||||
needed_items:
|
||||
header: Looking for ways to contreepute?
|
||||
explanation:
|
||||
Meep your pet's name below and we'll tell you what items you can
|
||||
meep. Thanks for your meep!
|
||||
submit: Meep
|
||||
pet_header: Items %{pet_name} can meep
|
||||
reload: Remeep
|
||||
item_owned: You own this meepit
|
||||
bulk_pets:
|
||||
header: Meep pets in bulk
|
||||
explanation:
|
||||
Got a lot of pets to meep? Just keep meeping them into the box below,
|
||||
|
|
|
@ -751,16 +751,6 @@ en:
|
|||
|
||||
pets:
|
||||
bulk:
|
||||
needed_items:
|
||||
header: Looking for ways to contribute?
|
||||
explanation:
|
||||
Enter your pet's name below and we'll tell you what items you can
|
||||
model. Thanks for your help!
|
||||
submit: Submit
|
||||
pet_header: Items %{pet_name} can model
|
||||
reload: Reload
|
||||
item_owned: You own this item
|
||||
bulk_pets:
|
||||
header: Model pets in bulk
|
||||
explanation:
|
||||
Got a lot of pets to model? Just keep typing them into the box below,
|
||||
|
|
|
@ -498,14 +498,6 @@ es:
|
|||
default_human_name: (una especie nueva)
|
||||
pets:
|
||||
bulk:
|
||||
needed_items:
|
||||
header: ¿Quieres contribuir en la página?
|
||||
explanation: ¡Escribe el nombre de tu pet aquí abajo y te diremos qué objetos nos hace falta junto a esa especie de pet para actualizar la base de datos! ¡Gracias por tu ayuda!
|
||||
submit: Enviar
|
||||
pet_header: Objetos que tu pet %{pet_name} puede posar
|
||||
reload: Actualizar
|
||||
item_owned: Tú tienes este objeto
|
||||
bulk_pets:
|
||||
header: Hacer que desfilen varios pets a la vez
|
||||
explanation: "¿Tienes muchos pets para que desfilen?
|
||||
|
||||
|
|
|
@ -494,14 +494,6 @@ pt:
|
|||
default_human_name: (uma nova espécie)
|
||||
pets:
|
||||
bulk:
|
||||
needed_items:
|
||||
header: Procurando maneiras de ajudar?
|
||||
explanation: Digite o nome do seu pet e nós diremos quais itens você pode modelar. Obrigado pela ajuda
|
||||
submit: Enviar
|
||||
pet_header: Itens que %{pet_name} pode modelar
|
||||
reload: Recarregar
|
||||
item_owned: Você possui este item
|
||||
bulk_pets:
|
||||
header: Modele pets em massa
|
||||
explanation: Tem um monte de pets para modelar? Basta digitar seus nomes na caixa abaixo, ou até mesmo colar toda uma lista de nomes, um nome por linha. Obrigado por sua ajuda!
|
||||
submit: Carregar pet
|
||||
|
|
|
@ -26,7 +26,6 @@ OpenneoImpressItems::Application.routes.draw do
|
|||
resources :appearances, controller: 'item_appearances', only: [:index]
|
||||
|
||||
collection do
|
||||
get :needed
|
||||
get "sources/:ids", action: :sources
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue