Compare commits
3 commits
7f356cdede
...
8a8dd468be
Author | SHA1 | Date | |
---|---|---|---|
8a8dd468be | |||
d84ab44771 | |||
903fb19d5c |
2 changed files with 15 additions and 38 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) {
|
||||||
|
@ -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();
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue