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)
 
(65 intermediate revisions by one other user not shown)
Line 1: Line 1:
// --- COMMON.JS CLEANED AND UPDATED ---
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');
// --- Dropdown-based Tier Assignment ---
mw.loader.load('/index.php?title=MediaWiki:BingoSheet.js&action=raw&ctype=text/javascript');
mw.loader.using('jquery').then(function () {
mw.loader.load('/index.php?title=MediaWiki:TeamBingo.js&action=raw&ctype=text/javascript');
    console.log("✅ Dropdown-based Tier Assignment is running");
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');
    document.addEventListener('DOMContentLoaded', function () {
mw.loader.load('/index.php?title=MediaWiki:VoteBoostToggle.js&action=raw&ctype=text/javascript');
        function moveItemToTier(itemId, tierId) {
            var item = document.getElementById(itemId);
            var targetTier = document.getElementById(tierId);
            if (item && targetTier) {
                targetTier.appendChild(item);
            }
        }
 
        var selectors = document.querySelectorAll('.tier-selector');
        selectors.forEach(function(sel) {
            sel.addEventListener('change', function () {
                moveItemToTier(this.id, this.value);
            });
        });
    });
});
 
// --- Bingo JS ---
mw.loader.using('mediawiki.util', function () {
    document.addEventListener("DOMContentLoaded", function () {
        console.log("✅ Bingo JS Loaded");
 
        var tiles = document.querySelectorAll(".bingo-table td .lighttable-cell");
        tiles.forEach(function(tile) {
            var 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.addEventListener("DOMContentLoaded", function() {
    var tables = document.querySelectorAll(".skill-info-calc");
    tables.forEach(function(table){
        var xpPerAction = parseInt(table.querySelector("span.total-xp").textContent);
        var numActionsElem = table.querySelector(".num-actions");
        var totalXPElem = table.querySelector(".total-xp");
 
        table.querySelector(".increase").addEventListener("click", function() {
            var actions = parseInt(numActionsElem.textContent) + 1;
            numActionsElem.textContent = actions;
            totalXPElem.textContent = actions * xpPerAction;
        });
 
        table.querySelector(".decrease").addEventListener("click", function() {
            var actions = parseInt(numActionsElem.textContent) - 1;
            if (actions < 0) actions = 0;
            numActionsElem.textContent = actions;
            totalXPElem.textContent = actions * xpPerAction;
        });
    });
});
 
// --- Simple Calculator ---
document.addEventListener("DOMContentLoaded", function() {
    const container = document.getElementById("calcContainer");
    if (!container) return;
 
    // Build calculator HTML dynamically
    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>
    `;
 
    // Add calculator functionality
    const btn = document.getElementById("calcButton");
    btn.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');