MediaWiki:Common.js: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
(add vote boost for drop rate calcs)
 
(64 intermediate revisions by one other user not shown)
Line 1: Line 1:
// COMMON.JS MINIMAL SAFE VERSION
mw.loader.load('/index.php?title=MediaWiki:DropCalc.js&action=raw&ctype=text/javascript');
document.addEventListener("DOMContentLoaded", function() {
mw.loader.load('/index.php?title=MediaWiki:SlayerPointsCalc.js&action=raw&ctype=text/javascript');
    console.log("✅ Common.js Loaded");
mw.loader.load('/index.php?title=MediaWiki:BingoSheet.js&action=raw&ctype=text/javascript');
 
mw.loader.load('/index.php?title=MediaWiki:TeamBingo.js&action=raw&ctype=text/javascript');
    // --- Tier Assignment ---
mw.loader.load('/index.php?title=MediaWiki:Tierlist.js&action=raw&ctype=text/javascript');
    document.querySelectorAll('.tier-selector').forEach(function(sel) {
mw.loader.load('/index.php?title=MediaWiki:SmoothiesDebtCalculator.js&action=raw&ctype=text/javascript');
        sel.addEventListener('change', function() {
mw.loader.load('/index.php?title=MediaWiki:VoteBoostToggle.js&action=raw&ctype=text/javascript');
            const item = document.getElementById(this.id);
            const targetTier = document.getElementById(this.value);
            if (item && targetTier) targetTier.appendChild(item);
        });
    });
 
    // --- Bingo ---
    document.querySelectorAll(".bingo-table td .lighttable-cell").forEach(function(tile) {
        const id = tile.dataset.key || tile.id;
        if (!id) return;
        if (localStorage.getItem(id) === "selected") tile.classList.add("bingo-selected");
 
        tile.addEventListener("click", function() {
            tile.classList.toggle("bingo-selected");
            if (tile.classList.contains("bingo-selected")) {
                localStorage.setItem(id, "selected");
            } else {
                localStorage.removeItem(id);
            }
        });
    });
 
    // --- Skill XP Calculator ---
    document.querySelectorAll(".skill-info-calc").forEach(function(table){
        const xpPerAction = parseInt(table.querySelector("span.total-xp").textContent);
        const numActionsElem = table.querySelector(".num-actions");
        const totalXPElem = table.querySelector(".total-xp");
 
        table.querySelector(".increase").addEventListener("click", function() {
            let actions = parseInt(numActionsElem.textContent) + 1;
            numActionsElem.textContent = actions;
            totalXPElem.textContent = actions * xpPerAction;
        });
 
        table.querySelector(".decrease").addEventListener("click", function() {
            let actions = parseInt(numActionsElem.textContent) - 1;
            if (actions < 0) actions = 0;
            numActionsElem.textContent = actions;
            totalXPElem.textContent = actions * xpPerAction;
        });
    });
 
    // --- Simple Calculator ---
    const container = document.getElementById("calcContainer");
    if (container) {
        container.innerHTML = `
            <div style="margin:10px 0;">
                <label>Num1: <input type="number" id="num1" value="0" style="width:60px;"></label>
                <label>Num2: <input type="number" id="num2" value="0" style="width:60px;"></label>
                <label>Operation:
                    <select id="op">
                        <option value="+">+</option>
                        <option value="-">-</option>
                        <option value="*">*</option>
                        <option value="/">/</option>
                    </select>
                </label>
                <button id="calcButton">Calculate</button>
            </div>
            <div>Result: <span id="result">0</span></div>
        `;
 
        document.getElementById("calcButton").addEventListener("click", function() {
            const a = parseFloat(document.getElementById("num1").value);
            const b = parseFloat(document.getElementById("num2").value);
            const op = document.getElementById("op").value;
            let result;
 
            if (isNaN(a) || isNaN(b)) {
                result = "Enter valid numbers";
            } else {
                switch(op) {
                    case "+": result = a + b; break;
                    case "-": result = a - b; break;
                    case "*": result = a * b; break;
                    case "/": result = b !== 0 ? a / b : "∞"; break;
                    default: result = "Error";
                }
            }
            document.getElementById("result").textContent = result;
        });
    }
});

Latest revision as of 21:24, 18 July 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');
mw.loader.load('/index.php?title=MediaWiki:TeamBingo.js&action=raw&ctype=text/javascript');
mw.loader.load('/index.php?title=MediaWiki:Tierlist.js&action=raw&ctype=text/javascript');
mw.loader.load('/index.php?title=MediaWiki:SmoothiesDebtCalculator.js&action=raw&ctype=text/javascript');
mw.loader.load('/index.php?title=MediaWiki:VoteBoostToggle.js&action=raw&ctype=text/javascript');