var categories = {
aspects: "",
basic: "thaumcraft",
thaumaturgy: "thaumcraft",
alchemy: "thaumcraft",
artifice: "thaumcraft",
golemancy: "thaumcraft",
enchanting: "thaumic_tinkerer",
extras: "thaumcraft_extras",
apimancy: "magic_bees",
traheremagy: "railcraft"
};
var mods = {
thaumcraft: true,
thaumic_tinkerer: true,
advanced_thaumaturgy: true,
thaumcraft_extras: true,
magic_bees: true,
electric_magic_tools: true,
thaumcraft_gates: true,
player_beacons: true,
railcraft: true,
better_storage: true
};
var modShortTerms = {
thaumcraft: "",
thaumic_tinkerer: "[TT]",
advanced_thaumaturgy: "[AT]",
thaumcraft_extras: "[TE]",
magic_bees: "[MB]",
electric_magic_tools: "[EM]",
thaumcraft_gates: "[TG]",
player_beacons: "[PB]",
railcraft: "[RC]",
better_storage: "[BS]"
};
var modResearchTooltips = {
thaumcraft: "",
thaumic_tinkerer: "This research entry comes from the Thaumic Tinkerer addon",
advanced_thaumaturgy: "This research entry comes from the Advanced Thaumaturgy addon",
thaumcraft_extras: "This research entry comes from the Thaumcraft Extras addon",
magic_bees: "This research entry comes from the Magic Bees addon",
electric_magic_tools: "This research entry comes from the Electric Magic Tools addon",
thaumcraft_gates: "This research entry comes from the ThaumcraftGates addon",
player_beacons: "This research entry comes from the Player Beacons addon",
railcraft: "This research entry comes from the Railcraft addon",
better_storage: "This research entry comes from the Better Storage addon"
};
var aspectsShown = [];
var researchData = { };
var aspectsForResearch = { };
var currentCategory;
var currentAspect;
var aspectsTabText;
var filter = "";
var firstResearch = false;
String.prototype.contains = function(str) {
return this.indexOf(str) != -1;
};
String.prototype.containsIgnoreCase = function(str) {
return this.toLowerCase().contains(str.toLowerCase());
};
String.prototype.replaceAll = function(original, source) {
return this.split(original).join(source);
};
function setCategory(category) {
var hash = category;
var aspect = "";
var research = "";
var skipHash = false;
if(category.substring(0, 8) == "aspects_") {
aspect = category.substring("aspects_".length);
category = "aspects";
skipHash = true;
}
if(!(category in categories)) {
if(category.contains(":")) {
category = category.substring(0, category.indexOf(":"));
research = hash.substring(hash.indexOf(":") + 1, hash.length);
skipHash = true;
} else category = "basic";
}
currentCategory = category;
for(cat in categories)
$("#category_" + cat).attr("src", "images/categories/category_" + cat + (cat === category ? "_selected" : "_deselected") + ".png");
if(!skipHash)
document.location.hash = category;
if(category === "aspects") {
$("#text").html(aspectsTabText);
$("#input").text("");
if(aspect.length != 0) {
setAspect(aspect, false);
}
} else {
$("#text").html(generateResearchForText());
$("#input").html("
");
$("#searchBar").watermark("Look up a research (Tip: press ESC to clear this text)");
$("#searchBar").val(filter);
if(research.length != 0)
setSearchText(research.replaceAll("_", " "));
}
for(cat in categories)
$("#category_" + cat).attr("width", categories[cat].length == 0 || mods[categories[cat]] || categories[cat] === "thaumcraft" ? 48 : 0);
}
function generateResearchForText() {
var text = "";
if(!(currentCategory in researchData))
text = "That category doesn't exist.";
else {
firstResearch = true;
for(research in researchData[currentCategory])
text = appendResearchToText(research, text);
}
if(text.length == 0)
text = "No research was found for that search.";
return text;
}
function appendResearchToText(research, text) {
var researchObj = researchData[currentCategory][research];
if(!mods[researchObj.mod] || (filter.legth != 0 && !researchObj.name.containsIgnoreCase(filter)))
return text;
if(!firstResearch)
text += "";
text += "
" + researchObj.name + "
";
text += "";
var aspects = researchObj.aspects;
var sideText = "(Starts off unlocked) ";
if(aspects.length != 0) {
sideText = "";
var aspectText = "";
for(aspect in aspects)
aspectText += aspectImg(aspects[aspect], 32, 32) + " ";
aspectsForResearch[researchObj.name] = aspectText;
sideText += "
" + (aspectsShown.indexOf(researchObj.name) > -1 ? aspectText : "(Click to show research aspects)") + "
";
}
text += "
" + sideText + "
";
text += "";
text += " " + modShortTerms[researchObj.mod] + " " + researchObj.lore + " ";
text += "Nature: " + researchObj.nature + " ";
var recipes = researchObj.recipes;
var hasRecipes = false;
for(recipe in recipes) {
if(!hasRecipes)
text += "Recipes: ";
var url = recipes[recipe];
text += "[" + recipe.replaceAll("_", " ") + "] ";
hasRecipes = true;
}
if(hasRecipes)
text += " ";
text += " " + researchObj.description.replaceAll("", "
";
if(aspects[aspect].type === "primal")
text += "(Primal Aspect)";
else {
text += aspectImg(aspects[aspect].component1, 32, 32) + " " + aspectImg(aspects[aspect].component2, 32, 32) + " ";
text += aspects[aspect].component1 + " + " + aspects[aspect].component2;
text += "
(Click to show possible creation path)
";
}
if(setHash)
document.location.hash = "aspects_" + aspect;
$("#aspect_box").html(text);
}
function setSearchText(text) {
filter = text;
$("#searchBar").val(text);
$("#text").html(generateResearchForText());
}
function clearSearch() {
filter = "";
$("#searchBar").val("");
$("#text").html(generateResearchForText());
}
$(function() {
loadAspects(); // from aspects.js
for(mod in mods) {
var cookie = $.cookie(mod);
mods[mod] = (cookie === "true" ? true : (mod == "thaumcraft"));
$("#cb_" + mod).prop("checked", mods[mod]);
}
researchData["basic"] = research_basic; // from basic.js
researchData["thaumaturgy"] = research_thaumaturgy; // from thaumaturgy.js
researchData["alchemy"] = research_alchemy; // from alchemy.js
researchData["artifice"] = research_artifice; // from artifice.js
researchData["golemancy"] = research_golemancy; // from golemancy.js
researchData["enchanting"] = research_enchanting; // from enchanting.js
researchData["extras"] = research_extras; // from extras.js
researchData["apimancy"] = research_apimancy; // from apimancy.js
researchData["traheremagy"] = research_traheremagy; // from traheremagy.js
setAspectText();
var hash = document.location.hash.substring("1");
setCategory(hash);
$(document).tooltip({
items: "a",
content: function() {
if($(this).attr("class") === "recipe_img")
return "";
}
});
});
function setAspectText() {
var text = "
All Aspects Index: ";
var i = 0;
for(aspect in aspects) {
var mod = aspects[aspect].mod;
if(!mods[mod])
continue;
text += aspectImg(aspects[aspect].name, 32, 32);
if(i == 5 || (i - 6) % 9 == 8) {
text += " ";
if(i == 5 && mods["thaumcraft"])
text += " ";
}
++i;
}
text += "
(Click an aspect in the index to see it's components)