[#21] Add support for linking to a certain recipe
This commit is contained in:
+32
-2
@@ -14,12 +14,18 @@ $(function() {
|
||||
$("#crafting_selector").change(onCraftingSelectorChanged);
|
||||
$("#crafting_count").change(onCraftingSelectorChanged);
|
||||
|
||||
loadRecipebook("data/vanilla.json");
|
||||
loadRecipebook("data/buildcraft.json");
|
||||
loadRecipebook("data/vanilla.json", function() {
|
||||
loadRecipebook("data/buildcraft.json", function() {
|
||||
parseUrlParameters();
|
||||
onCraftingSelectorChanged();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function onCraftingSelectorChanged() {
|
||||
var recipeName = $("#crafting_selector option:selected").val();
|
||||
if (recipeName === undefined) return;
|
||||
|
||||
var recipe = findRecipe(recipeName);
|
||||
if (recipe === undefined) {
|
||||
$("#crafting_error").html("Cannot find recipe for " + recipeName);
|
||||
@@ -77,6 +83,30 @@ function loadRecipebook(recipebookUrl, onSuccess) {
|
||||
});
|
||||
}
|
||||
|
||||
function parseUrlParameters() {
|
||||
var quantity = $.url().param('quantity');
|
||||
if (quantity !== undefined) {
|
||||
$("#crafting_count").val(quantity);
|
||||
|
||||
if ($("#crafting_count option:selected").val() === undefined) {
|
||||
$("#crafting_count").val(1);
|
||||
|
||||
$("#crafting_error").html("Unsupported quantity: " + quantity);
|
||||
$("#crafting_error").fadeIn(FADE_DURATION).delay(ERROR_DISPLAY_DURATION).fadeOut(FADE_DURATION);
|
||||
}
|
||||
}
|
||||
|
||||
var recipeName = $.url().param('recipeName');
|
||||
if (recipeName !== undefined) {
|
||||
$("#crafting_selector").val(recipeName);
|
||||
|
||||
if ($("#crafting_selector option:selected").val() === undefined) {
|
||||
$("#crafting_error").html("Cannot find recipe for " + recipeName);
|
||||
$("#crafting_error").fadeIn(FADE_DURATION).delay(ERROR_DISPLAY_DURATION).fadeOut(FADE_DURATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateCraftingSelector() {
|
||||
var $selector = $("#crafting_selector");
|
||||
$selector.html("");
|
||||
|
||||
Reference in New Issue
Block a user