MediaWiki:Common.js

From Emps-World Wiki
Revision as of 11:52, 30 August 2018 by Thomy (Talk | contribs)

Jump to: navigation, search

Note: After saving, 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: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences
/* Any JavaScript here will be loaded for all users on every page load. */


$(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 hc = 0, dc = 0;

            // iterate over headers
            table.find("th").each(function() {
                if (hc === 0)
                    $(this).text("searching for item "+itemId);
                hc++;
            })
            
            // iterate over table data
            table.find("td").each(function() {
                if (dc === 0)
                    $(this).text(data.mlAcc);
                else if (dc === 1)
                    $(this).text(data.rnAcc);
                else if (dc === 2)
                    $(this).text(data.mgAcc);
                else if (dc === 3)
                    $(this).text(data.mlDef);
                else if (dc === 4)
                    $(this).text(data.rnDef);
                else if (dc === 5)
                    $(this).text(data.mgDef);
                else if (dc == 6)
                    $(this).text(data.prayer);
                else if (dc == 7)
                    $(this).text("slot todo");
                else if (dc === 8)
                    $(this).text(data.mlStr);
                else if (dc === 9)
                    $(this).text(data.rnStr);
                else if (dc === 10)
                    $(this).text(data.mgStr);
                else if (dc === 11)
                    $(this).text("degrade todo");
                else if (dc === 12)
                    $(this).text("repair todo");
                else if (dc === 13)
                    $(this).text("requirement todo");
                else if (dc === 14)
                    $(this).text("attack speed todo");
                else
                    $(this).text(dc+" data column");
                dc++;
            });
        });
    });
});