|
|
| (54 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| // --- COMMON.JS: Minimal Calculator (ES5 safe) ---
| | 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("calcContainer");
| | mw.loader.load('/index.php?title=MediaWiki:BingoSheet.js&action=raw&ctype=text/javascript'); |
| if (!container) return;
| |
| | |
| 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>';
| |
| | |
| var btn = document.getElementById("calcButton");
| |
| btn.onclick = function () {
| |
| var a = parseFloat(document.getElementById("num1").value);
| |
| var b = parseFloat(document.getElementById("num2").value);
| |
| var op = document.getElementById("op").value;
| |
| var 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;
| |
| };
| |
| });
| |
| // --- DROPRATE CALCULATOR ---
| |
| mw.hook('wikipage.content').add(function () { | |
| var container = document.getElementById("dropCalcContainer");
| |
| if (!container) return;
| |
| | |
| // Build HTML using string concatenation
| |
| container.innerHTML =
| |
| '<div style="margin:10px 0;">' +
| |
| '<label>Base Drop Rate: <input type="number" id="baseRate" value="1000" style="width:80px;"></label><br><br>' +
| |
| | |
| '<label>Donator Rank Bonus: ' +
| |
| '<select id="donatorBonus">' +
| |
| '<option value="0">None</option>' +
| |
| '<option value="10">Bronze 10%</option>' +
| |
| '<option value="25">Silver 25%</option>' +
| |
| '<option value="45">Divine 45%</option>' +
| |
| '</select>' +
| |
| '</label><br><br>' +
| |
| | |
| '<label>Vote Bonus: ' +
| |
| '<select id="voteBonus">' +
| |
| '<option value="0">None</option>' +
| |
| '<option value="10">10%</option>' +
| |
| '<option value="20">20%</option>' +
| |
| '<option value="30">30%</option>' +
| |
| '</select>' +
| |
| '</label><br><br>' +
| |
| | |
| '<label>Skull Bonus: ' +
| |
| '<select id="skullBonus">' +
| |
| '<option value="0">None</option>' +
| |
| '<option value="5">5%</option>' +
| |
| '<option value="15">15%</option>' +
| |
| '<option value="25">25%</option>' +
| |
| '</select>' +
| |
| '</label><br><br>' +
| |
| | |
| '<button id="calcDropBtn">Calculate Drop Rate</button>' +
| |
| '</div>' +
| |
| '<div>Final Drop Rate: <span id="finalDrop">0</span></div>';
| |
| | |
| // 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 vote = parseFloat(document.getElementById("voteBonus").value) || 0;
| |
| var skull = parseFloat(document.getElementById("skullBonus").value) || 0;
| |
| | |
| // Calculate final drop rate with bonuses
| |
| var finalRate = base;
| |
| finalRate += finalRate * donator / 100;
| |
| finalRate += finalRate * vote / 100;
| |
| finalRate += finalRate * skull / 100;
| |
| | |
| document.getElementById("finalDrop").textContent = Math.round(finalRate);
| |
| };
| |
| });
| |