MediaWiki:Common.js: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
No edit summary
 
(25 intermediate revisions by the same user not shown)
Line 1: Line 1:
// --- DROPRATE CALCULATOR (ES5 Table Version, Styled Cells) ---
mw.loader.load('/index.php?title=MediaWiki:DropCalc.js&action=raw&ctype=text/javascript');
mw.hook('wikipage.content').add(function () {
mw.loader.load('/index.php?title=MediaWiki:SlayerPointsCalc.js&action=raw&ctype=text/javascript');
    var container = document.getElementById("dropCalcContainer");
mw.loader.load('/index.php?title=MediaWiki:BingoSheet.js&action=raw&ctype=text/javascript');
    if (!container) return;
 
    // Build HTML using ES5 string concatenation
    var html = '';
    html += '<table style="border-collapse:collapse;margin:10px 0;width:450px;">';
    html += '<tr><td>Base Drop Rate:</td><td><input type="number" id="baseRate" value="1000" style="width:80px;"></td></tr>';
 
    html += '<tr><td>Donator Rank Bonus:</td><td>';
    html += '<select id="donatorBonus">';
    html += '<option value="0">None</option>';
    html += '<option value="15">Donator 15%</option>';
    html += '<option value="25">Super Donator 25%</option>';
    html += '<option value="30">Extreme Donator 30%</option>';
    html += '<option value="35">Legendary Donator 35%</option>';
    html += '<option value="40">Royal Donator 40%</option>';
    html += '<option value="45">Divine Donator 45%</option>';
    html += '</select></td></tr>';
 
    html += '<tr><td>Monster Slayer Perk:</td><td>';
    html += '<select id="slayerBonus">';
    html += '<option value="0">None</option>';
    html += '<option value="10">10%</option>';
    html += '</select></td></tr>';
 
    html += '<tr><td>Collector\'s Ring Bonus:</td><td>';
    html += '<select id="ringBonus">';
    html += '<option value="0">None</option>';
    html += '<option value="3">3%</option>';
    html += '<option value="6">6%</option>';
    html += '</select></td></tr>';
 
    html += '<tr><td>Skull Bonus:</td><td>';
    html += '<select id="skullBonus">';
    html += '<option value="0">None</option>';
    html += '<option value="20">20%</option>';
    html += '</select></td></tr>';
 
    html += '<tr><td>Voting Bonus:</td><td>';
    html += '<select id="voteBonus">';
    html += '<option value="0">None</option>';
    html += '<option value="20">20%</option>';
    html += '</select></td></tr>';
 
    html += '<tr><td colspan="2" style="text-align:center;"><button id="calcDropBtn" style="margin-top:10px;">Calculate Drop Rate</button></td></tr>';
    html += '</table>';
 
    html += '<div style="margin-top:10px;font-weight:bold;">Final Drop Rate: <span id="finalDrop">0</span></div>';
 
    // Table to show step-by-step calculation
    html += '<table id="dropSteps" style="border-collapse:collapse;margin-top:10px;width:450px;">';
    html += '<tr style="background:#444;color:#fff;"><th style="padding:4px;border:1px solid #999;">Bonus</th><th style="padding:4px;border:1px solid #999;">Percentage</th><th style="padding:4px;border:1px solid #999;">Drop Rate</th></tr>';
    html += '</table>';
 
    container.innerHTML = html;
 
    // Calculation
    var btn = document.getElementById("calcDropBtn");
    btn.onclick = function () {
        var base = parseFloat(document.getElementById("baseRate").value) || 0;
        var donator = parseFloat(document.getElementById("donatorBonus").value) || 0;
        var slayer = parseFloat(document.getElementById("slayerBonus").value) || 0;
        var ring = parseFloat(document.getElementById("ringBonus").value) || 0;
        var skull = parseFloat(document.getElementById("skullBonus").value) || 0;
        var vote = parseFloat(document.getElementById("voteBonus").value) || 0;
 
        var finalRate = base;
        var stepsTable = document.getElementById("dropSteps");
        // Remove old rows except header
        while(stepsTable.rows.length > 1){ stepsTable.deleteRow(1); }
 
        function addStep(name, perc) {
            finalRate *= (1 - perc / 100);
            var row = stepsTable.insertRow();
            row.style.background = '#f9f9f9';
            row.style.border = '1px solid #ccc';
            var cell1 = row.insertCell(0);
            var cell2 = row.insertCell(1);
            var cell3 = row.insertCell(2);
            cell1.style.padding = '4px'; cell1.style.border = '1px solid #ccc';
            cell2.style.padding = '4px'; cell2.style.border = '1px solid #ccc';
            cell3.style.padding = '4px'; cell3.style.border = '1px solid #ccc';
            cell1.innerHTML = name;
            cell2.innerHTML = perc + '%';
            cell3.innerHTML = Math.round(finalRate);
        }
 
        addStep("Donator Bonus", donator);
        addStep("Monster Slayer", slayer);
        addStep("Collector's Ring", ring);
        addStep("Skull Bonus", skull);
        addStep("Voting Bonus", vote);
 
        document.getElementById("finalDrop").textContent = Math.round(finalRate);
    };
});

Latest revision as of 02:04, 7 March 2026

mw.loader.load('/index.php?title=MediaWiki:DropCalc.js&action=raw&ctype=text/javascript');
mw.loader.load('/index.php?title=MediaWiki:SlayerPointsCalc.js&action=raw&ctype=text/javascript');
mw.loader.load('/index.php?title=MediaWiki:BingoSheet.js&action=raw&ctype=text/javascript');