Compare commits

...

3 commits

Author SHA1 Message Date
8a8dd468be Improve handling of image hash pet names on the homepage
Closes #3, by adapting the suggested changes! Thank you!!

We both change how we create pet name preview jobs, by catching the `@`
case early; and we better handle symbols in pet names when showing the
thank you message, by parsing the query string more correctly.

Co-Authored-By: Steve C <diceroll123@gmail.com>
2024-09-09 18:25:56 -07:00
d84ab44771 Fix response when modeling pet from Modeling Hub homepage form
This was always modeling correctly, but not showing the message,
because Turbo doesn't handle anchors in redirect URLs the same way the
browser's full page loads do.

I forget why we had this as a `#` URL anyway to begin with. Use `?`
instead!
2024-09-09 18:17:09 -07:00
903fb19d5c Remove some unused code from outfits/new.js
This whole file could probably be made a LOT smaller and simpler but
hey, I'm not in the mood lol!
2024-09-09 18:11:03 -07:00
2 changed files with 15 additions and 38 deletions

View file

@ -6,12 +6,9 @@
var PetQuery = {}, var PetQuery = {},
query_string = document.location.hash || document.location.search; query_string = document.location.hash || document.location.search;
$.each(query_string.substr(1).split("&"), function () { for (const [key, value] of new URLSearchParams(query_string).entries()) {
var split_piece = this.split("="); PetQuery[key] = value;
if (split_piece.length == 2) {
PetQuery[split_piece[0]] = split_piece[1];
} }
});
if (PetQuery.name) { if (PetQuery.name) {
if (PetQuery.species && PetQuery.color) { if (PetQuery.species && PetQuery.color) {
@ -69,21 +66,6 @@
}, },
}; };
function loadNotable() {
// TODO: add HTTPS to notables
// $.getJSON('https://notables.openneo.net/api/1/days/ago/1?callback=?', function (response) {
// var notables = response.notables;
// var i = Math.floor(Math.random() * notables.length);
// Preview.Job.fallback = new Preview.Job.Name(notables[i].petName);
// if(!Preview.Job.current) {
// Preview.Job.fallback.setAsCurrent();
// }
// });
if (!Preview.Job.current) {
Preview.Job.fallback.setAsCurrent();
}
}
function loadFeature() { function loadFeature() {
$.getJSON("/donations/features", function (features) { $.getJSON("/donations/features", function (features) {
if (features.length > 0) { if (features.length > 0) {
@ -92,8 +74,6 @@
if (!Preview.Job.current) { if (!Preview.Job.current) {
Preview.Job.fallback.setAsCurrent(); Preview.Job.fallback.setAsCurrent();
} }
} else {
loadNotable();
} }
}); });
} }
@ -106,16 +86,7 @@
job.loading = false; job.loading = false;
function getImageSrc() { function getImageSrc() {
if (key.substr(0, 3) === "a:-") { if (base === "cp" || base === "cpn") {
// lol lazy code for prank image :P
// TODO: HTTPS?
return (
"https://swfimages.impress.openneo.net" +
"/biology/000/000/0-2/" +
key.substr(2) +
"/300x300.png"
);
} else if (base === "cp" || base === "cpn") {
return petImage(base + "/" + key, quality); return petImage(base + "/" + key, quality);
} else if (base === "url") { } else if (base === "url") {
return key; return key;
@ -148,7 +119,13 @@
Preview.Job.Name = function (name) { Preview.Job.Name = function (name) {
this.name = name; this.name = name;
if (name.startsWith("@")) {
// This is an image hash "pet name".
Preview.Job.apply(this, [name.substr(1), "cp"]);
} else {
// This is a normal pet name.
Preview.Job.apply(this, [name, "cpn"]); Preview.Job.apply(this, [name, "cpn"]);
}
this.visit = function () { this.visit = function () {
$(".main-pet-name").val(this.name).closest("form").submit(); $(".main-pet-name").val(this.name).closest("form").submit();

View file

@ -14,7 +14,7 @@ class PetsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
path = destination + @pet.wardrobe_query path = destination + "?" + @pet.wardrobe_query
redirect_to path redirect_to path
end end
@ -38,9 +38,9 @@ class PetsController < ApplicationController
def destination def destination
case (params[:destination] || params[:origin]) case (params[:destination] || params[:origin])
when 'wardrobe' then wardrobe_path + '?' when 'wardrobe' then wardrobe_path
when 'needed_items' then needed_items_path + '?' when 'needed_items' then needed_items_path
else root_path + '#' else root_path
end end
end end