MediaWiki:Calculator.js

Revision as of 17:22, 26 February 2011 by Cogniac (Talk | contribs) (Behold! Switch statement fall through.)

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
/**
 * Code for calculators.
 */
function Calculator(content, id, title, columns) {
    var location = document.getElementById(id);

    var table = document.createElement('table');
    table.className = 'uoguidetable open';

    var calcTableBody = document.createElement('tbody');
    table.appendChild(calcTableBody);

    var calcTableRow = document.createElement('tr');
    calcTableBody.appendChild(calcTableRow);

    var calcTableHeader = document.createElement('th');
    calcTableHeader.colSpan = columns;
    calcTableHeader.appendChild(document.createTextNode(title));
    calcTableRow.appendChild(calcTableHeader);

    calcTableRow = content;
    calcTableBody.appendChild(calcTableRow);

    location.appendChild(table);
}

switch (wgPageName) {
    case 'Luck':
        importScript('MediaWiki:Calculator.js/Luck.js');
        break;
    case 'Mana_Regeneration':
        importScript('MediaWiki:Calculator.js/Mana_Regeneration.js');
        break;
    case 'Vendor':
        importScript('MediaWiki:Calculator.js/Player_Vendor_Fee.js');
        break;
    case 'Swing_Speed':
    case 'Swing_Speed_Increase':
        importScript('MediaWiki:Calculator.js/Swing_Speed_Increase.js');
        break;
}