MediaWiki:SlayerPointsCalc.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
mw.hook('wikipage.content').add(function () { | mw.hook('wikipage.content').add(function () { | ||
// Only run on | // Only run on the correct page | ||
if (mw.config.get('wgPageName') !== "Slayer_points_calculator") return; | if (mw.config.get('wgPageName') !== "Slayer_points_calculator") return; | ||
| Line 7: | Line 7: | ||
if (!container) return; | if (!container) return; | ||
// Build UI | |||
container.innerHTML = | container.innerHTML = | ||
'<div style="margin-bottom:10px;">' + | '<div style="margin-bottom:10px;">' + | ||
| Line 15: | Line 16: | ||
'</select>' + | '</select>' + | ||
'</div>' + | '</div>' + | ||
'<table id="slayerTable" style="border-collapse:collapse; width:400px;">' + | '<table id="slayerTable" style="border-collapse:collapse; width:400px;">' + | ||
'<thead>' + | '<thead>' + | ||
'<tr style="background:#222e45;color:#fff;">' + | '<tr style="background:#222e45;color:#fff;">' + | ||
'<th style="padding:5px;text-align:left;">Task</th>' + | '<th style="padding:5px;text-align:left;">Task</th>' + | ||
'<th style="padding:5px;text-align:center;"> | '<th style="padding:5px;text-align:center;">Points</th>' + | ||
'</tr>' + | '</tr>' + | ||
'</thead>' + | '</thead>' + | ||
'<tbody></tbody>' + | '<tbody></tbody>' + | ||
'</table>'; | '</table>'; | ||
var basePoints = 25; // Base points for normal task | |||
var milestones = [ | var milestones = [ | ||
{name:"Normal task", | {name:"Normal task", multiplier:1}, | ||
{name:"10th task", | {name:"10th task", multiplier:5}, | ||
{name:"50th task", | {name:"50th task", multiplier:15}, | ||
{name:"100th task", | {name:"100th task", multiplier:25}, | ||
{name:"250th task", | {name:"250th task", multiplier:35}, | ||
{name:" | {name:"1,000th task", multiplier:50} | ||
]; | ]; | ||
| Line 38: | Line 41: | ||
milestones.forEach(function(milestone, index){ | milestones.forEach(function(milestone, index){ | ||
var row = tbody.insertRow(); | var row = tbody.insertRow(); | ||
row.style.background = index % 2 ? "#222e45" : "#313e59"; | row.style.background = index % 2 ? "#222e45" : "#313e59"; | ||
| Line 48: | Line 50: | ||
var cell2 = row.insertCell(); | var cell2 = row.insertCell(); | ||
cell2. | cell2.id = "points_" + index; | ||
cell2.style.textAlign = "center"; | cell2.style.textAlign = "center"; | ||
cell2.style.padding = "5px"; | |||
}); | }); | ||
function updatePoints(){ | function updatePoints() { | ||
var boost = parseFloat(document.getElementById("donatorBoost").value) || 0; | |||
var boost = parseFloat(document.getElementById("donatorBoost").value); | var multiplierBoost = 1 + boost/100; | ||
milestones.forEach(function(milestone, index){ | milestones.forEach(function(milestone, index){ | ||
var points = basePoints * milestone.multiplier * multiplierBoost; | |||
var | document.getElementById("points_" + index).textContent = Math.floor(points); | ||
document.getElementById(" | |||
}); | }); | ||
} | } | ||
| Line 73: | Line 68: | ||
updatePoints(); | updatePoints(); | ||
}); | }); | ||
Revision as of 00:41, 7 March 2026
mw.hook('wikipage.content').add(function () {
// Only run on the correct page
if (mw.config.get('wgPageName') !== "Slayer_points_calculator") return;
var container = document.getElementById("slayerCalcContainer");
if (!container) return;
// Build UI
container.innerHTML =
'<div style="margin-bottom:10px;">' +
'Donator Boost: ' +
'<select id="donatorBoost">' +
'<option value="0">None</option>' +
'<option value="75">Divine Donator (+75%)</option>' +
'</select>' +
'</div>' +
'<table id="slayerTable" style="border-collapse:collapse; width:400px;">' +
'<thead>' +
'<tr style="background:#222e45;color:#fff;">' +
'<th style="padding:5px;text-align:left;">Task</th>' +
'<th style="padding:5px;text-align:center;">Points</th>' +
'</tr>' +
'</thead>' +
'<tbody></tbody>' +
'</table>';
var basePoints = 25; // Base points for normal task
var milestones = [
{name:"Normal task", multiplier:1},
{name:"10th task", multiplier:5},
{name:"50th task", multiplier:15},
{name:"100th task", multiplier:25},
{name:"250th task", multiplier:35},
{name:"1,000th task", multiplier:50}
];
var tbody = document.querySelector("#slayerTable tbody");
milestones.forEach(function(milestone, index){
var row = tbody.insertRow();
row.style.background = index % 2 ? "#222e45" : "#313e59";
row.style.color = "#fff";
var cell1 = row.insertCell();
cell1.textContent = milestone.name;
cell1.style.padding = "5px";
var cell2 = row.insertCell();
cell2.id = "points_" + index;
cell2.style.textAlign = "center";
cell2.style.padding = "5px";
});
function updatePoints() {
var boost = parseFloat(document.getElementById("donatorBoost").value) || 0;
var multiplierBoost = 1 + boost/100;
milestones.forEach(function(milestone, index){
var points = basePoints * milestone.multiplier * multiplierBoost;
document.getElementById("points_" + index).textContent = Math.floor(points);
});
}
document.getElementById("donatorBoost").addEventListener("change", updatePoints);
updatePoints();
});