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,23 +1,5 @@
/** @jsx React.DOM */ /** @jsx React.DOM */
(function($, I18n) {
// Console-polyfill. MIT license.
// https://github.com/paulmillr/console-polyfill
// Make it safe to do console.log() always.
var console = (function (con) {
'use strict';
var prop, method;
var empty = {};
var dummy = function() {};
var properties = 'memory'.split(',');
var methods = ('assert,count,debug,dir,dirxml,error,exception,group,' +
'groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,' +
'time,timeEnd,trace,warn').split(',');
while (prop = properties.pop()) con[prop] = con[prop] || empty;
while (method = methods.pop()) con[method] = con[method] || dummy;
return con;
})(window.console || {});
var Neopia = { var Neopia = {
User: { User: {
get: function(id) { get: function(id) {
@ -51,6 +33,15 @@
return this.request(petId, "POST"); return this.request(petId, "POST");
} }
}, },
Status: {
get: function() {
return $.ajax({
dataType: "json",
url: Neopia.API_URL + "/status",
useCSRFProtection: false
});
}
},
init: function() { init: function() {
var hostEl = $('meta[name=neopia-host]'); var hostEl = $('meta[name=neopia-host]');
if (!hostEl.length) { if (!hostEl.length) {
@ -64,6 +55,24 @@
} }
}; };
(function($, I18n) {
// Console-polyfill. MIT license.
// https://github.com/paulmillr/console-polyfill
// Make it safe to do console.log() always.
var console = (function (con) {
'use strict';
var prop, method;
var empty = {};
var dummy = function() {};
var properties = 'memory'.split(',');
var methods = ('assert,count,debug,dir,dirxml,error,exception,group,' +
'groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,' +
'time,timeEnd,trace,warn').split(',');
while (prop = properties.pop()) con[prop] = con[prop] || empty;
while (method = methods.pop()) con[method] = con[method] || dummy;
return con;
})(window.console || {});
var ImpressUser = (function() { var ImpressUser = (function() {
var userSignedIn = ($('meta[name=user-signed-in]').attr('content') === 'true'); var userSignedIn = ($('meta[name=user-signed-in]').attr('content') === 'true');
if (userSignedIn) { if (userSignedIn) {

View file

@ -4,8 +4,7 @@ var disqus_shortname = 'dresstoimpress';
var preview_el = $('#pet-preview'), var preview_el = $('#pet-preview'),
img_el = preview_el.find('img'), img_el = preview_el.find('img'),
response_el = preview_el.find('span'), response_el = preview_el.find('span');
name_el = $('#main-pet-name');
var defaultPreviewUrl = img_el.attr('src'); var defaultPreviewUrl = img_el.attr('src');
@ -29,7 +28,7 @@ var Preview = {
response_el.empty(); response_el.empty();
$('#preview-' + key + '-template').tmpl(options).appendTo(response_el); $('#preview-' + key + '-template').tmpl(options).appendTo(response_el);
}, },
updateWithName: function () { updateWithName: function (name_el) {
var name = name_el.val(), job; var name = name_el.val(), job;
if(name) { if(name) {
currentName = name; currentName = name;
@ -117,7 +116,7 @@ Preview.Job.Name = function (name) {
Preview.Job.apply(this, [name, 'cpn']); Preview.Job.apply(this, [name, 'cpn']);
this.visit = function() { 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 () { $(function () {
var previewWithNameTimeout; var previewWithNameTimeout;
var name_el = $('.main-pet-name');
name_el.val(PetQuery.name); name_el.val(PetQuery.name);
Preview.updateWithName(); Preview.updateWithName(name_el);
name_el.keyup(function () { name_el.keyup(function () {
if(previewWithNameTimeout) { if(previewWithNameTimeout) {
clearTimeout(previewWithNameTimeout); clearTimeout(previewWithNameTimeout);
Preview.Job.current.loading = false; 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 () { img_el.load(function () {
@ -284,12 +287,22 @@ $(function () {
} }
} }
$('#load-pet-to-wardrobe').submit(function(e) { $('.load-pet-to-wardrobe').submit(function(e) {
if (name_el.val() === "" && Preview.Job.current) { if ($(this).find('.main-pet-name').val() === "" && Preview.Job.current) {
e.preventDefault(); e.preventDefault();
Preview.Job.current.visit(); 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() { function addDisqusCount() {

View file

@ -47,18 +47,29 @@ body.outfits-new
left: 16px left: 16px
legend legend
margin-left: -16px margin-left: -16px
#load-pet-to-wardrobe .primary
font-size: 175%
margin: margin:
bottom: 1em bottom: 2em
top: 1.5em top: 3em
input input
font-size: 67% font-size: 115%
padding: .5em padding: .5em
width: 10em width: 10em
button button
+loud-awesome-button +loud-awesome-button
font-size: 67% 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 #description, #top-contributors
float: left float: left
#description #description

View file

@ -41,7 +41,7 @@ class OutfitsController < ApplicationController
end end
def new 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 @colors = Color.funny.alphabetical
@species = Species.alphabetical @species = Species.alphabetical
end end

View file

@ -13,24 +13,45 @@
%h1= t 'app_name' %h1= t 'app_name'
%h2= t '.tagline' %h2= t '.tagline'
= form_tag remote_load_pet_path, method: 'GET', id: 'load-pet-to-wardrobe' do %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) = hidden_field_tag 'impress_user', current_user.try(:id)
- localized_cache action_suffix: 'outfits#new main_load_pet_form_content' do - localized_cache action_suffix: 'outfits#new neopia_online main_load_pet_form_content' do
= hidden_field_tag 'redirect', "#{wardrobe_url}\#{q}" = hidden_field_tag 'redirect', "#{wardrobe_url}\#{q}"
%fieldset %fieldset
%legend= t '.load_pet.legend' %legend= t '.neopia_online.load_pet'
= pet_name_tag :id => 'main-pet-name' = pet_name_tag class: 'main-pet-name'
%button{:type => "submit"} %button{:type => "submit"}
= t '.load_pet.submit' = t '.submit.primary'
- localized_cache "outfits#new start_from_scratch_form pranks_funny=#{Color.pranks_funny?}" do - localized_cache "outfits#new neopia_online start_from_scratch_form pranks_funny=#{Color.pranks_funny?}" do
= form_tag wardrobe_path, method: 'GET', id: 'start-from-scratch', authenticity_token: false do = form_tag wardrobe_path, method: 'GET', class: 'secondary start-from-scratch', authenticity_token: false do
%fieldset %fieldset
%legend= t '.start_from_scratch.legend' %legend= t '.neopia_online.start_from_scratch'
= pet_attribute_select 'color', @colors, 8 = pet_attribute_select 'color', @colors, 8
= pet_attribute_select 'species', @species = pet_attribute_select 'species', @species
%button{:type => "submit"} %button{:type => "submit"}
= t('.start_from_scratch.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 %ul#sections
- localized_cache :action_suffix => 'your_items_module' do - localized_cache :action_suffix => 'your_items_module' do
@ -122,4 +143,4 @@
- content_for :javascripts do - content_for :javascripts do
= include_javascript_libraries :jquery20, :jquery_tmpl = include_javascript_libraries :jquery20, :jquery_tmpl
= modeling_i18n_tag = 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: pet_type_not_found:
We haven't meeped a %{color_name} %{species_name}. Meep? We haven't meeped a %{color_name} %{species_name}. Meep?
pet_not_found: Pet not meeped. pet_not_found: Pet not meeped.
load_pet: submit:
legend: Enter your pet's meep primary: Meep my outfit!
submit: Meep my outfit! secondary: Meep
start_from_scratch: neopia_online:
legend: Or meep from scratch load_pet: Enter your pet's meep
submit: Meep start_from_scratch: Or meep from scratch
your_items: your_items:
tagline: Meep and meep! tagline: Meep and meep!
description: description:

View file

@ -685,6 +685,17 @@ en:
pet_type_not_found: pet_type_not_found:
We haven't seen a %{color_name} %{species_name}. Have you? We haven't seen a %{color_name} %{species_name}. Have you?
pet_not_found: Pet not found. 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: load_pet:
legend: Enter your pet's name legend: Enter your pet's name
submit: Plan my outfit! submit: Plan my outfit!

View file

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

View file

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