1
0
Fork 0
forked from OpenNeo/impress

get upset when we neopets.com bans us :P

This commit is contained in:
Emi Matchu 2015-07-15 00:09:17 -04:00
parent 169c587e42
commit 093ae27ae8
9 changed files with 168 additions and 103 deletions

View file

@ -1,5 +1,60 @@
/** @jsx React.DOM */
var Neopia = {
User: {
get: function(id) {
return $.ajax({
dataType: "json",
url: Neopia.API_URL + "/users/" + id,
useCSRFProtection: false
}).then(function(response) {
return response.users[0];
});
}
},
Customization: {
request: function(petId, type) {
var data = {};
if (ImpressUser.id) {
data.impress_user = ImpressUser.id;
}
return $.ajax({
dataType: "json",
type: type,
url: Neopia.API_URL + "/pets/" + petId + "/customization",
useCSRFProtection: false,
data: data
});
},
get: function(petId) {
return this.request(petId, "GET");
},
post: function(petId) {
return this.request(petId, "POST");
}
},
Status: {
get: function() {
return $.ajax({
dataType: "json",
url: Neopia.API_URL + "/status",
useCSRFProtection: false
});
}
},
init: function() {
var hostEl = $('meta[name=neopia-host]');
if (!hostEl.length) {
throw "missing neopia-host meta tag";
}
var host = hostEl.attr('content');
if (!host) {
throw "neopia-host meta tag exists, but is empty";
}
Neopia.API_URL = "http://" + host + "/api/1";
}
};
(function($, I18n) {
// Console-polyfill. MIT license.
// https://github.com/paulmillr/console-polyfill
@ -18,52 +73,6 @@
return con;
})(window.console || {});
var Neopia = {
User: {
get: function(id) {
return $.ajax({
dataType: "json",
url: Neopia.API_URL + "/users/" + id,
useCSRFProtection: false
}).then(function(response) {
return response.users[0];
});
}
},
Customization: {
request: function(petId, type) {
var data = {};
if (ImpressUser.id) {
data.impress_user = ImpressUser.id;
}
return $.ajax({
dataType: "json",
type: type,
url: Neopia.API_URL + "/pets/" + petId + "/customization",
useCSRFProtection: false,
data: data
});
},
get: function(petId) {
return this.request(petId, "GET");
},
post: function(petId) {
return this.request(petId, "POST");
}
},
init: function() {
var hostEl = $('meta[name=neopia-host]');
if (!hostEl.length) {
throw "missing neopia-host meta tag";
}
var host = hostEl.attr('content');
if (!host) {
throw "neopia-host meta tag exists, but is empty";
}
Neopia.API_URL = "http://" + host + "/api/1";
}
};
var ImpressUser = (function() {
var userSignedIn = ($('meta[name=user-signed-in]').attr('content') === 'true');
if (userSignedIn) {

View file

@ -4,8 +4,7 @@ var disqus_shortname = 'dresstoimpress';
var preview_el = $('#pet-preview'),
img_el = preview_el.find('img'),
response_el = preview_el.find('span'),
name_el = $('#main-pet-name');
response_el = preview_el.find('span');
var defaultPreviewUrl = img_el.attr('src');
@ -29,7 +28,7 @@ var Preview = {
response_el.empty();
$('#preview-' + key + '-template').tmpl(options).appendTo(response_el);
},
updateWithName: function () {
updateWithName: function (name_el) {
var name = name_el.val(), job;
if(name) {
currentName = name;
@ -117,7 +116,7 @@ Preview.Job.Name = function (name) {
Preview.Job.apply(this, [name, 'cpn']);
this.visit = function() {
name_el.val(this.name).closest('form').submit();
$('.main-pet-name').val(this.name).closest('form').submit();
}
}
@ -153,15 +152,19 @@ Preview.Job.Feature = function(feature) {
$(function () {
var previewWithNameTimeout;
var name_el = $('.main-pet-name');
name_el.val(PetQuery.name);
Preview.updateWithName();
Preview.updateWithName(name_el);
name_el.keyup(function () {
if(previewWithNameTimeout) {
clearTimeout(previewWithNameTimeout);
Preview.Job.current.loading = false;
}
previewWithNameTimeout = setTimeout(Preview.updateWithName, 250);
var name_el = $(this);
previewWithNameTimeout = setTimeout(function() {
Preview.updateWithName(name_el);
}, 250);
});
img_el.load(function () {
@ -284,12 +287,22 @@ $(function () {
}
}
$('#load-pet-to-wardrobe').submit(function(e) {
if (name_el.val() === "" && Preview.Job.current) {
$('.load-pet-to-wardrobe').submit(function(e) {
if ($(this).find('.main-pet-name').val() === "" && Preview.Job.current) {
e.preventDefault();
Preview.Job.current.visit();
}
});
function setNeopiaStatus(isOnline) {
$('#outfit-forms').attr('data-neopia-status', isOnline ? 'online' : 'offline');
}
Neopia.Status.get().then(function(r) {
setNeopiaStatus(!!r.status);
}).fail(function() {
setNeopiaStatus(false);
});
});
function addDisqusCount() {

View file

@ -47,18 +47,29 @@ body.outfits-new
left: 16px
legend
margin-left: -16px
#load-pet-to-wardrobe
font-size: 175%
margin:
bottom: 1em
top: 1.5em
input
font-size: 67%
padding: .5em
width: 10em
button
+loud-awesome-button
font-size: 67%
.primary
margin:
bottom: 2em
top: 3em
input
font-size: 115%
padding: .5em
width: 10em
button
+loud-awesome-button
legend
font-size: 175%
select
font-size: 120%
[data-require-neopia-status=offline]
display: none
&[data-neopia-status=offline]
[data-require-neopia-status=online]
display: none
[data-require-neopia-status=offline]
display: block
[data-require-neopia-status=offline] .load-pet-to-wardrobe legend a
font-size: 85%
#description, #top-contributors
float: left
#description

View file

@ -41,7 +41,7 @@ class OutfitsController < ApplicationController
end
def new
unless localized_fragment_exist?("outfits#new start_from_scratch_form pranks_funny=#{Color.pranks_funny?}")
unless localized_fragment_exist?("outfits#new neopia_online start_from_scratch_form pranks_funny=#{Color.pranks_funny?}") && localized_fragment_exist?("outfits#new neopia_offline start_from_scratch_form pranks_funny=#{Color.pranks_funny?}")
@colors = Color.funny.alphabetical
@species = Species.alphabetical
end

View file

@ -13,24 +13,45 @@
%h1= t 'app_name'
%h2= t '.tagline'
= form_tag remote_load_pet_path, method: 'GET', id: 'load-pet-to-wardrobe' do
= hidden_field_tag 'impress_user', current_user.try(:id)
- localized_cache action_suffix: 'outfits#new main_load_pet_form_content' do
= hidden_field_tag 'redirect', "#{wardrobe_url}\#{q}"
%fieldset
%legend= t '.load_pet.legend'
= pet_name_tag :id => 'main-pet-name'
%button{:type => "submit"}
= t '.load_pet.submit'
%div{'data-require-neopia-status' => 'online'}
= form_tag remote_load_pet_path, method: 'GET', class: 'primary load-pet-to-wardrobe' do
= hidden_field_tag 'impress_user', current_user.try(:id)
- localized_cache action_suffix: 'outfits#new neopia_online main_load_pet_form_content' do
= hidden_field_tag 'redirect', "#{wardrobe_url}\#{q}"
%fieldset
%legend= t '.neopia_online.load_pet'
= pet_name_tag class: 'main-pet-name'
%button{:type => "submit"}
= t '.submit.primary'
- localized_cache "outfits#new start_from_scratch_form pranks_funny=#{Color.pranks_funny?}" do
= form_tag wardrobe_path, method: 'GET', id: 'start-from-scratch', authenticity_token: false do
%fieldset
%legend= t '.start_from_scratch.legend'
= pet_attribute_select 'color', @colors, 8
= pet_attribute_select 'species', @species
%button{:type => "submit"}
= t('.start_from_scratch.submit')
- localized_cache "outfits#new neopia_online start_from_scratch_form pranks_funny=#{Color.pranks_funny?}" do
= form_tag wardrobe_path, method: 'GET', class: 'secondary start-from-scratch', authenticity_token: false do
%fieldset
%legend= t '.neopia_online.start_from_scratch'
= pet_attribute_select 'color', @colors, 8
= pet_attribute_select 'species', @species
%button{:type => "submit"}
= t('.submit.secondary')
%div{'data-require-neopia-status' => 'offline'}
- localized_cache "outfits#new neopia_offline start_from_scratch_form pranks_funny=#{Color.pranks_funny?}" do
= form_tag wardrobe_path, method: 'GET', class: 'primary start-from-scratch', authenticity_token: false do
%fieldset
%legend= t '.neopia_offline.start_from_scratch'
= pet_attribute_select 'color', @colors, 8
= pet_attribute_select 'species', @species
%button{:type => "submit"}
= t('.submit.primary')
= form_tag remote_load_pet_path, method: 'GET', class: 'secondary load-pet-to-wardrobe' do
= hidden_field_tag 'impress_user', current_user.try(:id)
- localized_cache action_suffix: 'outfits#new neopia_offline main_load_pet_form_content' do
= hidden_field_tag 'redirect', "#{wardrobe_url}\#{q}"
%fieldset
%legend= t '.neopia_offline.load_pet.main_html', link: link_to(t('.neopia_offline.load_pet.link_content'), 'http://blog.openneo.net/')
= pet_name_tag class: 'main-pet-name'
%button{:type => "submit"}
= t '.submit.secondary'
%ul#sections
- localized_cache :action_suffix => 'your_items_module' do
@ -122,4 +143,4 @@
- content_for :javascripts do
= include_javascript_libraries :jquery20, :jquery_tmpl
= modeling_i18n_tag
= javascript_include_tag 'ajax_auth', 'react', 'jquery.timeago', 'pet_query', 'outfits/new', 'modeling'
= javascript_include_tag 'ajax_auth', 'react', 'jquery.timeago', 'pet_query', 'modeling', 'outfits/new'

View file

@ -609,12 +609,12 @@ en-MEEP:
pet_type_not_found:
We haven't meeped a %{color_name} %{species_name}. Meep?
pet_not_found: Pet not meeped.
load_pet:
legend: Enter your pet's meep
submit: Meep my outfit!
start_from_scratch:
legend: Or meep from scratch
submit: Meep
submit:
primary: Meep my outfit!
secondary: Meep
neopia_online:
load_pet: Enter your pet's meep
start_from_scratch: Or meep from scratch
your_items:
tagline: Meep and meep!
description:

View file

@ -685,6 +685,17 @@ en:
pet_type_not_found:
We haven't seen a %{color_name} %{species_name}. Have you?
pet_not_found: Pet not found.
submit:
primary: Plan my outfit!
secondary: Go
neopia_online:
load_pet: Enter your pet's name
start_from_scratch: Or start from scratch
neopia_offline:
start_from_scratch: Choose a pet to get started
load_pet:
main_html: Or try your pet's name %{link}
link_content: (but it looks like Neopets.com is ignoring us)
load_pet:
legend: Enter your pet's name
submit: Plan my outfit!

View file

@ -476,12 +476,12 @@ es:
preview:
pet_type_not_found: No hemos encontrado aun a un %{species_name} %{color_name}. ¿Lo has hecho tú?
pet_not_found: Pet no encontrado.
load_pet:
legend: Escribe el nombre de tu pet
submit: ¡Diseñar mi atuendo!
start_from_scratch:
legend: O empieza a partir de una plantilla
submit: Ir
submit:
primary: ¡Diseñar mi atuendo!
secondary: Ir
neopia_online:
load_pet: Escribe el nombre de tu pet
start_from_scratch: O empieza a partir de una plantilla
your_items:
tagline: ¡Añade e intercambia!
description: Crea listas de los objetos que tú tienes y quieres. ¡Compártelas con el mundo!

View file

@ -474,12 +474,12 @@ pt:
preview:
pet_type_not_found: Nós nunca vimos um %{species_name} %{color_name} . Você viu?
pet_not_found: Pet não encontrado.
load_pet:
legend: Digite o nome do seu pet
submit: Planeje minha roupa!
start_from_scratch:
legend: Ou comece do zero
submit: Vai
submit:
primary: Planeje minha roupa!
secondary: Vai
neopia_online:
load_pet: Digite o nome do seu pet
start_from_scratch: Ou comece do zero
your_items:
tagline: Acompanhe e troque!
description: Faça listas de itens que você tem e que procura, e compartilhe com o mundo.