MediaWiki:SlayerPointsCalc.js: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
function initSlayerPointsCalculator(container) {
if (mw.config.get('wgPageName') !== "Slayer_points_calculator") return;


const html = `
mw.hook('wikipage.content').add(function () {
 
if (document.getElementById("slayerPointsCalc")) return;
 
const container = document.createElement("div");
container.id = "slayerPointsCalc";
 
container.innerHTML = `
<h3>Slayer Points Calculator</h3>
<h3>Slayer Points Calculator</h3>


Line 21: Line 28:
`;
`;


container.innerHTML = html;
document.querySelector(".mw-parser-output").appendChild(container);


const tasks = [
const tasks = [
Line 58: Line 65:


updateTable();
updateTable();
}
 
});

Revision as of 00:33, 7 March 2026

if (mw.config.get('wgPageName') !== "Slayer_points_calculator") return;

mw.hook('wikipage.content').add(function () {

if (document.getElementById("slayerPointsCalc")) return;

const container = document.createElement("div");
container.id = "slayerPointsCalc";

container.innerHTML = `
<h3>Slayer Points Calculator</h3>

<label>Boost:</label>
<select id="boostSelect">
<option value="1">None</option>
<option value="1.75">Divine Donator (+75%)</option>
</select>

<table class="wikitable">
<thead>
<tr>
<th>Task Milestone</th>
<th>Slayer Points</th>
</tr>
</thead>
<tbody id="slayerTable"></tbody>
</table>
`;

document.querySelector(".mw-parser-output").appendChild(container);

const tasks = [
{ name: "Normal Task", points: 10 },
{ name: "Every 10th Task", points: 50 },
{ name: "Every 50th Task", points: 150 },
{ name: "Every 100th Task", points: 300 },
{ name: "Every 250th Task", points: 500 },
{ name: "Every 1000th Task", points: 1000 }
];

function updateTable() {

const multiplier = parseFloat(document.getElementById("boostSelect").value);

let html = "";

tasks.forEach(task => {

const boosted = Math.floor(task.points * multiplier);

html += `
<tr>
<td>${task.name}</td>
<td>${boosted}</td>
</tr>
`;

});

document.getElementById("slayerTable").innerHTML = html;

}

document.getElementById("boostSelect").addEventListener("change", updateTable);

updateTable();

});