MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
// mapping slot id to a name | // mapping slot id to a name | ||
var imgSize = "30px"; | |||
var slotToName = [ | var slotToName = [ | ||
"[[file:Helmetslot.png|"+imgSize+"]]", | |||
"[[file:Capeslot.png|"+imgSize+"]]", | |||
"[[file:Amuletslot.png|"+imgSize+"]]", | |||
"[[file:Weaponslot.png|"+imgSize+"]]", | |||
"[[file:Bodyslot.png|"+imgSize+"]]", | |||
"[[file:Shieldslot.png|"+imgSize+"]]", | |||
"Arms", | |||
"[[file:Legsslot.png|"+imgSize+"]]", | |||
"", | |||
"[[file:Glovesslot.png|"+imgSize+"]]", | |||
"[[file:Bootsslot.png|"+imgSize+"]]", | |||
"", | |||
"[[file:Ringslot.png|"+imgSize+"]]", | |||
"[[file:Ammoslot.png|"+imgSize+"]]", | |||
"[[file:Wingsslot.png|"+imgSize+"]]", | |||
"[[file:Auraslot.png|"+imgSize+"]]", | |||
]; | ]; | ||
Line 30: | Line 31: | ||
var hc = 0, dc = 0; | var hc = 0, dc = 0; | ||
console.log("data1: "+JSON.stringify(data)); | |||
console.log("data2: "+data); | |||
console.log("data3: "+json); | |||
console.log("data4: "+json.name); | |||
// iterate over headers | // iterate over headers |
Revision as of 12:57, 30 August 2018
/* Any JavaScript here will be loaded for all users on every page load. */ // mapping slot id to a name var imgSize = "30px"; var slotToName = [ "[[file:Helmetslot.png|"+imgSize+"]]", "[[file:Capeslot.png|"+imgSize+"]]", "[[file:Amuletslot.png|"+imgSize+"]]", "[[file:Weaponslot.png|"+imgSize+"]]", "[[file:Bodyslot.png|"+imgSize+"]]", "[[file:Shieldslot.png|"+imgSize+"]]", "Arms", "[[file:Legsslot.png|"+imgSize+"]]", "", "[[file:Glovesslot.png|"+imgSize+"]]", "[[file:Bootsslot.png|"+imgSize+"]]", "", "[[file:Ringslot.png|"+imgSize+"]]", "[[file:Ammoslot.png|"+imgSize+"]]", "[[file:Wingsslot.png|"+imgSize+"]]", "[[file:Auraslot.png|"+imgSize+"]]", ]; $(document).ready(function() { $(".item-bonus-table").each(function() { var table = $(this); var itemId = $(this).data("item-id"); $.get( "../scripts/fetch_item.php", { id: itemId }).done(function(data) { var json = JSON.parse(data); var hc = 0, dc = 0; console.log("data1: "+JSON.stringify(data)); console.log("data2: "+data); console.log("data3: "+json); console.log("data4: "+json.name); // iterate over headers table.find("th").each(function() { if (hc === 0) $(this).text(json.name); hc++; }) // iterate over table data table.find("td").each(function() { if (dc === 0) $(this).text(json.mlAcc); else if (dc === 1) $(this).text(json.rnAcc); else if (dc === 2) $(this).text(json.mgAcc); else if (dc === 3) $(this).text(json.mlDef); else if (dc === 4) $(this).text(json.rnDef); else if (dc === 5) $(this).text(json.mgDef); else if (dc == 6) $(this).text(json.prayer); else if (dc == 7) $(this).text(slotToName[json.slot]); else if (dc === 8) $(this).text(json.mlStr); else if (dc === 9) $(this).text(json.rnStr); else if (dc === 10) $(this).text(json.mgStr); else if (dc === 11) $(this).text(json.degrade === 1 ? "Yes" : "No"); else if (dc === 12) $(this).text(json.repair === 1 ? "Yes" : "No"); else if (dc === 13) $(this).text(json.req); else if (dc === 14) $(this).text(json.speed); else $(this).text(dc+" data column"); dc++; }); }); }); });