";
} else {
skill_chart = "";
}
var bm = false;
var tds = document.getElementsByTagName("td");
for(var i in tds) {
if(tds[i].innerHTML == "Sign:") {
i *= 1;
if(tds[i + 1].innerHTML == "Bad Moon") {
bm = true;
}
break;
}
}
var coloring_classes = [];
for(var i in skills) {
if(skills[i][1]) {
var classes = skills[i][1].split(" ");
for(var j = 0; j < classes.length; j++) {
if(total_sums[classes[j]]) {
total_sums[classes[j]]++;
coloring_classes[classes[j]].push(i);
} else {
total_sums[classes[j]] = 1;
coloring_classes[classes[j]] = [i];
}
}
total_total++;
}
}
var hardcore_skills = hardcore_total > 0;
var softcore_skills = softcore_total > 0 && softcore_total > hardcore_total;
var suppress_first_column = GM_getValue("suppress_first_column", "false") == "true";
var show_key = GM_getValue("show_key", "true") == "true";
var instructions = parsed_data.table;
row: for(var rowindex in instructions) {
var broken = false;
var first_column = true;
var row_style = "";
var row = instructions[rowindex];
cell: for(var colindex in row) {
var cell = row[colindex];
if(typeof(cell.display) != "undefined") {
var conditions = cell.display.split(" ");
for(var conditionindex in conditions) {
switch(conditions[conditionindex]) {
case "softcore-only":
if(!softcore_skills) {
continue cell;
}
if(hardcore_skills) {
continue cell;
}
break;
case "hardcore-only":
if(softcore_skills) {
continue cell;
}
if(!hardcore_skills) {
continue cell;
}
break;
case "both":
if(!softcore_skills) {
continue cell;
}
if(!hardcore_skills) {
continue cell;
}
break;
case "softcore":
if(!softcore_skills) {
continue cell;
}
break;
case "hardcore":
if(!hardcore_skills) {
continue cell;
}
break;
case "profile":
if(window.location.pathname == "/charsheet.php") {
continue cell;
}
break;
case "charsheet":
if(window.location.pathname != "/charsheet.php") {
continue cell;
}
break;
case "badmoon":
if(window.location.pathname != "/charsheet.php") {
continue cell;
}
if(!bm) {
continue cell;
}
break;
case "inbadmoon":
if(window.location.pathname != "/charsheet.php") {
continue cell;
}
if(!bm || !hardcore) {
continue cell;
}
break;
case "insoftcore":
if(window.location.pathname != "/charsheet.php") {
continue cell;
}
if(hardcore) {
continue cell;
}
break;
case "inhardcore":
if(window.location.pathname != "/charsheet.php") {
continue cell;
}
if(!hardcore) {
continue cell;
}
if(bm) {
continue cell;
}
break;
case "key":
if(!show_key) {
continue cell;
}
break;
}
}
}
if(first_column && suppress_first_column) {
first_column = false;
continue;
}
first_column = false;
if(!broken) {
broken = true;
skill_chart += row_break();
}
var cell_style = "";
if(cell.color == "row") {
if(!row_style) {
var row_skills = [];
for(var anothercolindex in row) {
if(row[anothercolindex].type == "skill") {
row_skills.push(row[anothercolindex].skill);
}
}
row_style = choose_style(row_skills, cell.colorbound, cell.threshold);
}
cell_style = row_style;
} else if(typeof(cell.color) != "undefined" && cell.color) {
var relevant_classes = cell.color.split(" ");
var coloring_list = [];
for(var classindex in relevant_classes) {
var this_class = relevant_classes[classindex];
coloring_list = coloring_list.concat(coloring_classes[this_class]);
}
cell_style = choose_style(coloring_list, cell.colorbound, cell.threshold);
}
if(typeof(cell.forcepermanence) != "undefined") {
cell_style = lookup_style(parseInt(cell.forcepermanence));
}
switch(cell.type) {
case "wiki":
skill_chart += wiki_cell(cell.content, cell.href, cell_style);
break;
case "text":
skill_chart += text_cell(cell.content, cell_style);
break;
case "skill":
skill_chart += skill_cell(cell.skill);
break;
case "sum":
var x = 0;
var y = 0;
var sums;
if(typeof(cell.flavor) != "undefined" && cell.flavor == "hardcore") {
sums = hardcore_sums;
} else {
sums = softcore_sums;
}
var relevant_classes = cell.class.split(" ");
var coloring_list = [];
for(var classindex in relevant_classes) {
var this_class = relevant_classes[classindex];
if(typeof(total_sums[this_class]) != "undefined") {
if(typeof(sums[this_class]) != "undefined") {
x += sums[this_class];
}
y += total_sums[this_class];
coloring_list = coloring_list.concat(coloring_classes[this_class]);
}
}
cell_label = cell.label ? cell.label : "";
skill_chart += text_cell(x + "/" + y + cell_label, choose_style(coloring_list, cell.colorbound, cell.threshold));
break;
}
}
}
if(unknowns.length > 0) {
skill_chart += row_break() + text_cell("") + text_cell("") + text_cell("") + text_cell("") + text_cell("") + text_cell("");
for(var i=0; i
| ";
} else {
skill_chart += " ";
}
var permalink = "";
for(var linkindex in parsed_data.permalink) {
var triplet = parsed_data.permalink[linkindex];
permalink += encodeSkills(triplet[0], triplet[1], triplet[2]);
}
str = new String(permalink);
permalink = str.replace(/A*$/, "");
var final_block = permalink.replace(/(.{4})*(.*)/, "$2");
// Pad out the final block of the Base64 with zeroes. We don't try to use '='
// to terminate the block because this requires care to avoid ending up with
// '__==' or similar, which is invalid Base64. The remote site will trim any
// trailing zeroes anyway.
if(final_block.length == 1) {
permalink += "AAA";
} else if(final_block.length == 2) {
permalink += "AA";
} else if(final_block.length == 3) {
permalink += "A";
}
if(window.location.pathname == "/charsheet.php") {
// charsheet
for(var i in document.getElementsByTagName("p")) {
str = new String(document.getElementsByTagName("p")[i].innerHTML);
if(str.match(/Skills:/)) {
str = str.replace(/(.*<\/table>)/, "$1 ";
document.getElementsByTagName("p")[i].innerHTML = str.replace(/Skills:<\/b>/, "Skills: [link]");
}
}
} else {
// showplayer
str = new String(document.getElementById("pskills"));
if(document.getElementById("pskills") == null) {
// This is an error case, we should have given up much sooner if we couldn't find a skill list.
GM_log("Couldn't find pskills list, so couldn't inject a chart.");
} else {
var old_chart = document.getElementById("pskills").innerHTML.replace(/\n/g, " ").replace(/\s+/g, " ").replace(/^.*>View Permanent Skills<\/a><\/td><\/tr> (.*)<\/td><\/tr><\/tbody><\/table>/, "$1").replace(/ class=\"pskill\"/g, "");
document.getElementById("pskills").innerHTML = "";
}
}
}
function create_checkbox_div(name, text, def) {
var div = document.createElement("div");
var input = document.createElement("input");
var label = document.createElement("label");
input.type = "checkbox";
input.value = "0";
input.checked = GM_getValue(name, def) == "true";
input.name = "skill_checker_" + name;
input.id = "skill_checker_" + name;
label.for = "skill_checker_" + name;
label.appendChild(document.createTextNode(text));
var callback = function() {
GM_setValue(name, input.checked ? "true" : "false");
}
input.addEventListener("change", callback, true);
div.appendChild(input);
div.appendChild(label);
return div;
}
function add_account_menu_options() {
var options = document.createElement("table");
options.width = "95%";
options.cellSpacing = "0";
options.cellPadding = "0";
options.innerHTML = " | Skill Checker Options | | | ";
var hook = document.getElementById("ro");
hook.parentNode.insertBefore(options, hook);
var form = document.getElementById("skill_checker_options_form");
form.appendChild(create_checkbox_div("suppress_first_column", "Suppress First Column", "false"));
form.appendChild(create_checkbox_div("show_key", "Show Key", "true"));
form.appendChild(create_checkbox_div("compact", "Use abbreviations instead of skill names", "false"));
form.appendChild(create_checkbox_div("wiki_links", "Skills link to wiki instead of in-game description", "false"));
form.appendChild(create_checkbox_div("no_borders", "Always fill boxes even when skill is unavailable", "false"));
}
if(window.location.pathname == "/main.php") {
update_data(data_url_list, null);
return;
} else if(window.location.pathname == "/account.php") {
add_account_menu_options();
return;
} else {
if(GM_getValue("json_data", "") == "") {
update_data(data_url_list, displaySkillTable);
} else{
displaySkillTable();
}
}
|