|
|
| (3 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| /* ===========================
| | = 🏆 Dungeon Leaderboard = |
| Dungeon Leaderboard Script
| |
| =========================== */
| |
|
| |
|
| mw.hook('wikipage.content').add(function ($content) {
| | ''Fastest verified dungeon completion times.'' |
|
| |
|
| const table = document.getElementById("leaderboardTable");
| | ---- |
| if (!table) return;
| |
|
| |
|
| const dungeonFilter = document.getElementById("filterDungeon");
| | == 📜 How To Submit == |
| const typeFilter = document.getElementById("filterType");
| |
| const addBtn = document.getElementById("addRunBtn");
| |
|
| |
|
| if (!addBtn) return;
| | # Upload your screenshot here: [[Special:Upload]] |
| | # Click '''Edit''' on this page |
| | # Copy the row template below |
| | # Paste it at the bottom of the table |
| | # Save |
|
| |
|
| function parseTime(t) {
| | Row template: |
| if (!t || !t.includes(":")) return 999999;
| |
| const parts = t.split(":");
| |
| return parseInt(parts[0]) * 60 + parseInt(parts[1]);
| |
| }
| |
|
| |
|
| function sortAndRank() {
| | <pre> |
| const rows = Array.from(table.rows).slice(1);
| | |- |
| | | Dungeon Name |
| | | Player Name |
| | | 04:32 |
| | | [[File:YourScreenshot.png|120px]] |
| | </pre> |
|
| |
|
| rows.sort((a, b) => {
| | ---- |
| return parseTime(a.cells[6].innerText) - parseTime(b.cells[6].innerText);
| |
| });
| |
|
| |
|
| rows.forEach(row => table.appendChild(row));
| | == 🏆 Global Rankings == |
|
| |
|
| rows.forEach((row, index) => {
| | {| class="wikitable sortable" style="width:100%; text-align:center;" |
| const rankCell = row.cells[0];
| | ! Rank |
| if (index === 0) rankCell.innerHTML = "🥇 1";
| | ! Dungeon |
| else if (index === 1) rankCell.innerHTML = "🥈 2";
| | ! Player |
| else if (index === 2) rankCell.innerHTML = "🥉 3";
| | ! Time (MM:SS) |
| else rankCell.innerText = index + 1;
| | ! Screenshot |
| });
| |
| }
| |
|
| |
|
| function filterTable() {
| | |- |
| const selectedDungeon = dungeonFilter.value;
| | | 1 |
| const selectedType = typeFilter.value;
| | | Wolf's Den |
| | | qtpi |
| | | 01:10 |
| | | [[File:Example.png|120px]] |
|
| |
|
| Array.from(table.rows).slice(1).forEach(row => {
| | |} |
| const dungeon = row.cells[1].innerText.trim();
| |
| const type = row.cells[2].innerText.trim();
| |
| | |
| const show =
| |
| (selectedDungeon === "All" || dungeon === selectedDungeon) &&
| |
| (selectedType === "All" || type === selectedType);
| |
| | |
| row.style.display = show ? "" : "none";
| |
| });
| |
| }
| |
| | |
| if (dungeonFilter) dungeonFilter.addEventListener("change", filterTable);
| |
| if (typeFilter) typeFilter.addEventListener("change", filterTable);
| |
| | |
| addBtn.addEventListener("click", function () {
| |
| alert("Button working — modal should appear next.");
| |
| });
| |
| | |
| sortAndRank();
| |
| }); | |