Script tags cannot be included in wiki code, so MediaWiki:Common.js is where a script such as this should be stroed. The wiki code, however, allows you to both tell the script where you want the additional content to be inserted, and also allow your script, if constructed this way, to get data from the page content.
I'll give you an example. Suppose you want to add to the page a table with an item name, its ID and its image URL (just an example- if you want some sort of different info or not in a table, i could see what i can do). A good way to implement it is by adding to the article, in the place on which you want the table to be placed, the following wiki code (which can also be added as a wiki template):
<span class="itemdata" data-ids="1752560,1726152">Loading...</span>
On that example, data-ids
is a comma-separated list of item IDs for the table to load. Then, some additional javascript could be used to make the table:
function itemToTable(node, data) {
console.info("itemToTable for node:");
console.log(node);
var tbl = [];
for (var i in data.item_list) {
var a = data.item_list[i];
tbl.push(
'<tr>' +
'<td>' + a.item_id + '</td>' +
'<td>' + a.name.en + '</td>' +
'<td><a href="census.soe.com' + a.image_path + '">' + a.image_path.match(/\d+\.[^\.]+$/i)[0] + '</a></td>' +
'</tr>'
);
}
var thead = "<thead><tr><th>ID</th><th>Name</th><th>Icon</th></tr></thead>",
tbody = "<tbody>" + tbl.join("\n") + "</tbody>";
console.info("Replacing node:");
console.log(node);
$(node).replaceWith('<table class="wikitable">' + thead + tbody + '</table>');
}
$("span.itemdata").each(function() {
var currNode = this;
console.info("currNode:");
console.info(currNode);
loadItemJSON($(currNode).attr("data-ids").replace(/[^\d\,]/g, ""), function(data) {
itemToTable(currNode, data);
});
});
I haven't gone through what the API offers in a very detailed manner, but there are probably other useful things to get from it and more useful than the english name and the icon URL.