MediaWiki:Gadget-InfinityEmblems.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* child "row" formatting */
function format(data) {
var mvpTheme = data[7];
if(mvpTheme.length > 0){
mvpTheme = "<dt>MVP Theme</dt><dd>"+mvpTheme+"</dd>";
} else {
mvpTheme = "";
}
return "<dl>"+
"<dt>Description</dt><dd>"+data[6]+"</dd>"+
"<dt>How to Unlock</dt><dd>"+data[8]+"</dd>"+
mvpTheme+
"</dl>";
}
$(function(){
// only load on Acepedia:Sandbox and Ace_Combat_Infinity/Emblems
if(/^(82412|86993)$/.test(mw.config.get("wgArticleId"))){
// run a check to see if DataTables has loaded
const dTCheck = setInterval(function(){
if($(".datatable-emblems-aceinf.datatable-loaded").length){
// end the check
clearInterval(dTCheck);
// grab the table API
var table = $(".datatable-emblems-aceinf").DataTable();
// apply the event handler for clicking a row
$(".datatable-emblems-aceinf.datatable-loaded tbody").on("click", "td", function(){
// select the row that was clicked
var tr = $(this).closest("tr"); // for the icon
var row = table.row(tr); // for the API
if (row.child.isShown()){
row.child.hide();
tr.removeClass("shown");
} else {
row.child(format(row.data())).show();
tr.addClass("shown");
}
});
}
}, 250);
}
});