forked from OpenNeo/impress
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>
This commit is contained in:
parent
d84ab44771
commit
8a8dd468be
1 changed files with 10 additions and 7 deletions
|
@ -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) {
|
||||||
|
@ -122,7 +119,13 @@
|
||||||
|
|
||||||
Preview.Job.Name = function (name) {
|
Preview.Job.Name = function (name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
Preview.Job.apply(this, [name, "cpn"]);
|
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"]);
|
||||||
|
}
|
||||||
|
|
||||||
this.visit = function () {
|
this.visit = function () {
|
||||||
$(".main-pet-name").val(this.name).closest("form").submit();
|
$(".main-pet-name").val(this.name).closest("form").submit();
|
||||||
|
|
Loading…
Reference in a new issue