MediaWiki:Common.js: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:


     // Build the calculator HTML
     // Build the calculator HTML
     var html = ''
     var html = '';
        + '<div style="margin:10px 0;">'
    html += '<div>';
        + ' <label>Base Drop Rate: <input type="number" id="baseRate" value="1000" style="width:80px;"></label>'
    html += '<label>Base Drop Rate: <input type="number" id="baseRate" value="1000" style="width:80px;"></label>';
        + '</div>'
    html += '</div>';
        + '<div style="margin:10px 0;">'
    html += '<div>';
        + ' <label>Donator Bonus: '
    html += '<label>Donator Bonus: <select id="donatorBonus">';
        + '    <select id="donatorBonus">'
    html += '<option value="0">None</option>';
        + '     <option value="0">None</option>'
    html += '<option value="0.10">Bronze (10%)</option>';
        + '     <option value="0.10">Bronze (10%)</option>'
    html += '<option value="0.25">Divine (25%)</option>';
        + '     <option value="0.25">Divine (25%)</option>'
    html += '</select></label>';
        + '   </select>'
    html += '</div>';
        + '  </label>'
    html += '<div>';
        + '</div>'
    html += '<label>Vote Bonus: <select id="voteBonus">';
        + '<div style="margin:10px 0;">'
    html += '<option value="0">None</option>';
        + ' <label>Vote Bonus: '
    html += '<option value="0.05">5%</option>';
        + '    <select id="voteBonus">'
    html += '<option value="0.10">10%</option>';
        + '     <option value="0">None</option>'
    html += '</select></label>';
        + '     <option value="0.05">5%</option>'
    html += '</div>';
        + '     <option value="0.10">10%</option>'
    html += '<div>';
        + '   </select>'
    html += '<label>Skull Bonus: <select id="skullBonus">';
        + '  </label>'
    html += '<option value="0">None</option>';
        + '</div>'
    html += '<option value="0.05">5%</option>';
        + '<div style="margin:10px 0;">'
    html += '<option value="0.15">15%</option>';
        + ' <label>Skull Bonus: '
    html += '</select></label>';
        + '    <select id="skullBonus">'
    html += '</div>';
        + '     <option value="0">None</option>'
    html += '<div>';
        + '     <option value="0.05">5%</option>'
    html += '<button id="calcButton">Calculate Drop Rate</button>';
        + '     <option value="0.15">15%</option>'
    html += '</div>';
        + '   </select>'
    html += '<div>Final Drop Rate: <span id="finalRate">0</span></div>';
        + '  </label>'
        + '</div>'
        + '<div style="margin:10px 0;">'
        + ' <button id="calcButton">Calculate Drop Rate</button>'
        + '</div>'
        + '<div style="margin:10px 0;">Final Drop Rate: <span id="finalRate">0</span></div>';


     container.innerHTML = html;
     container.innerHTML = html;


     // Calculator logic
     // Add click handler
     var btn = document.getElementById("calcButton");
     var btn = document.getElementById("calcButton");
     btn.onclick = function() {
     btn.onclick = function() {
Line 51: Line 45:
         var skull = parseFloat(document.getElementById("skullBonus").value) || 0;
         var skull = parseFloat(document.getElementById("skullBonus").value) || 0;


        // Multiplicative reduction formula
         var finalRate = base * (1 - donator) * (1 - vote) * (1 - skull);
         var finalRate = base * (1 - donator) * (1 - vote) * (1 - skull);



Revision as of 02:45, 5 March 2026

// --- DROPRATE CALCULATOR ---
document.addEventListener("DOMContentLoaded", function() {
    var container = document.getElementById("calcContainer");
    if (!container) return;

    // Build the calculator HTML
    var html = '';
    html += '<div>';
    html += '<label>Base Drop Rate: <input type="number" id="baseRate" value="1000" style="width:80px;"></label>';
    html += '</div>';
    html += '<div>';
    html += '<label>Donator Bonus: <select id="donatorBonus">';
    html += '<option value="0">None</option>';
    html += '<option value="0.10">Bronze (10%)</option>';
    html += '<option value="0.25">Divine (25%)</option>';
    html += '</select></label>';
    html += '</div>';
    html += '<div>';
    html += '<label>Vote Bonus: <select id="voteBonus">';
    html += '<option value="0">None</option>';
    html += '<option value="0.05">5%</option>';
    html += '<option value="0.10">10%</option>';
    html += '</select></label>';
    html += '</div>';
    html += '<div>';
    html += '<label>Skull Bonus: <select id="skullBonus">';
    html += '<option value="0">None</option>';
    html += '<option value="0.05">5%</option>';
    html += '<option value="0.15">15%</option>';
    html += '</select></label>';
    html += '</div>';
    html += '<div>';
    html += '<button id="calcButton">Calculate Drop Rate</button>';
    html += '</div>';
    html += '<div>Final Drop Rate: <span id="finalRate">0</span></div>';

    container.innerHTML = html;

    // Add click handler
    var btn = document.getElementById("calcButton");
    btn.onclick = function() {
        var base = parseFloat(document.getElementById("baseRate").value) || 0;
        var donator = parseFloat(document.getElementById("donatorBonus").value) || 0;
        var vote = parseFloat(document.getElementById("voteBonus").value) || 0;
        var skull = parseFloat(document.getElementById("skullBonus").value) || 0;

        var finalRate = base * (1 - donator) * (1 - vote) * (1 - skull);

        document.getElementById("finalRate").textContent = finalRate.toFixed(2);
    };
});