Compare commits
No commits in common. "8a8dd468bee857dcde59a3d2dca9ebb9d7bbec73" and "7f356cdede718f69fc4a29b2a0d59f631c3e28a6" have entirely different histories.
8a8dd468be
...
7f356cdede
2 changed files with 38 additions and 15 deletions
|
@ -6,9 +6,12 @@
|
||||||
var PetQuery = {},
|
var PetQuery = {},
|
||||||
query_string = document.location.hash || document.location.search;
|
query_string = document.location.hash || document.location.search;
|
||||||
|
|
||||||
for (const [key, value] of new URLSearchParams(query_string).entries()) {
|
$.each(query_string.substr(1).split("&"), function () {
|
||||||
PetQuery[key] = value;
|
var split_piece = this.split("=");
|
||||||
}
|
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) {
|
||||||
|
@ -66,6 +69,21 @@
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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) {
|
||||||
|
@ -74,6 +92,8 @@
|
||||||
if (!Preview.Job.current) {
|
if (!Preview.Job.current) {
|
||||||
Preview.Job.fallback.setAsCurrent();
|
Preview.Job.fallback.setAsCurrent();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
loadNotable();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -86,7 +106,16 @@
|
||||||
job.loading = false;
|
job.loading = false;
|
||||||
|
|
||||||
function getImageSrc() {
|
function getImageSrc() {
|
||||||
if (base === "cp" || base === "cpn") {
|
if (key.substr(0, 3) === "a:-") {
|
||||||
|
// 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;
|
||||||
|
@ -119,13 +148,7 @@
|
||||||
|
|
||||||
Preview.Job.Name = function (name) {
|
Preview.Job.Name = function (name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
if (name.startsWith("@")) {
|
Preview.Job.apply(this, [name, "cpn"]);
|
||||||
// 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();
|
||||||
|
|
|
@ -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