Difference between revisions of "MediaWiki:Calculator.js"

m
m
 
(7 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
  */
 
  */
 
function Calculator(content, id, title, columns) {
 
function Calculator(content, id, title, columns) {
     this.content = content;
+
     var location = document.getElementById(id);
    this.id = id;
+
    this.title = title;
+
    this.columns = columns;
+
}
+
  
Calculator.prototype = {
+
     var table = document.createElement('table');
     display: function() {
+
    table.className = 'uoguidetable open';
        var location = document.getElementById(id);
+
  
        var table = document.createElement('table');
+
    var calcTableBody = document.createElement('tbody');
        table.className = 'uoguidetable open';
+
    table.appendChild(calcTableBody);
  
        var calcTableBody = document.createElement('tbody');
+
    var calcTableRow = document.createElement('tr');
        table.appendChild(calcTableBody);
+
    calcTableBody.appendChild(calcTableRow);
  
        var calcTableRow = document.createElement('tr');
+
    var calcTableHeader = document.createElement('th');
        calcTableBody.appendChild(calcTableRow);
+
    calcTableHeader.colSpan = columns;
 +
    calcTableHeader.appendChild(document.createTextNode(title));
 +
    calcTableRow.appendChild(calcTableHeader);
  
        var calcTableHeader = document.createElement('th');
+
    calcTableRow = content;
        calcTableHeader.colSpan = columns;
+
    calcTableBody.appendChild(calcTableRow);
        calcTableHeader.appendChild(document.createTextNode(title));
+
        calcTableRow.appendChild(calcTableHeader);
+
  
        calcTableRow = content;
+
    location.appendChild(table);
        calcTableBody.appendChild(calcTableRow);
+
}
 
+
        location.appendChild(table);
+
    }
+
};
+
  
 
switch (wgPageName) {
 
switch (wgPageName) {
Line 41: Line 32:
 
         importScript('MediaWiki:Calculator.js/Mana_Regeneration.js');
 
         importScript('MediaWiki:Calculator.js/Mana_Regeneration.js');
 
         break;
 
         break;
     case 'Vendor':
+
     case 'Swing_Speed':
         importScript('MediaWiki:Calculator.js/Player_Vendor_Fee.js');
+
    case 'Swing_Speed_Increase':
 +
         importScript('MediaWiki:Calculator.js/Swing_Speed_Increase.js');
 
         break;
 
         break;
 
}
 
}

Latest revision as of 04:21, 8 June 2011

/**
 * 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 'Swing_Speed':
    case 'Swing_Speed_Increase':
        importScript('MediaWiki:Calculator.js/Swing_Speed_Increase.js');
        break;
}