Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Dungeon Leadboard: Difference between revisions

From Treeverse
No edit summary
Tag: visualeditor-switched
No edit summary
Line 1: Line 1:
= Dungeon Run Leaderboard =
/* ===========================
  Dungeon Leaderboard Script
  =========================== */


<html>
mw.hook('wikipage.content').add(function ($content) {
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; flex-wrap:wrap; gap:10px;">


<div>
    const table = document.getElementById("leaderboardTable");
<h2 style="margin:0;">Global Speed Rankings</h2>
    if (!table) return;
<div style="font-size:14px; opacity:0.8;">
Fastest verified completion times across all Treeverse dungeons.
</div>
</div>


<div style="display:flex; gap:8px; flex-wrap:wrap;">
    const dungeonFilter = document.getElementById("filterDungeon");
<label><strong>Dungeon:</strong></label>
    const typeFilter = document.getElementById("filterType");
<select id="filterDungeon">
     const addBtn = document.getElementById("addRunBtn");
     <option value="All">All</option>
    <option>Wolf's Den</option>
    <option>Wolf's Den II</option>
    <option>Wolf's Den III</option>
    <option>The Red Nest</option>
    <option>For The Eggs</option>
    <option>Scarlet Revenge</option>
    <option>Scarlet Revenge II</option>
    <option>Promised One</option>
    <option>Promised One II</option>
    <option>Promised One III</option>
    <option>Lost and Found</option>
    <option>The Hostage</option>
    <option>Cactus On Fire</option>
    <option>Deep Echoes</option>
    <option>Deep Echoes II</option>
    <option>Deep Echoes III</option>
</select>


<label><strong>Type:</strong></label>
     if (!addBtn) return;
<select id="filterType">
     <option value="All">All</option>
    <option>Solo</option>
    <option>Party</option>
</select>


<button id="addRunBtn" style="padding:8px 14px; font-weight:bold; cursor:pointer;">
    function parseTime(t) {
➕ Submit Run
        if (!t || !t.includes(":")) return 999999;
</button>
        const parts = t.split(":");
</div>
        return parseInt(parts[0]) * 60 + parseInt(parts[1]);
    }


</div>
    function sortAndRank() {
</html>
        const rows = Array.from(table.rows).slice(1);
 
        rows.sort((a, b) => {
            return parseTime(a.cells[6].innerText) - parseTime(b.cells[6].innerText);
        });
 
        rows.forEach(row => table.appendChild(row));
 
        rows.forEach((row, index) => {
            const rankCell = row.cells[0];
            if (index === 0) rankCell.innerHTML = "🥇 1";
            else if (index === 1) rankCell.innerHTML = "🥈 2";
            else if (index === 2) rankCell.innerHTML = "🥉 3";
            else rankCell.innerText = index + 1;
        });
    }
 
    function filterTable() {
        const selectedDungeon = dungeonFilter.value;
        const selectedType = typeFilter.value;
 
        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();
});

Revision as of 23:53, 28 February 2026

/* ===========================

  Dungeon Leaderboard Script
  =========================== */

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

   const table = document.getElementById("leaderboardTable");
   if (!table) return;
   const dungeonFilter = document.getElementById("filterDungeon");
   const typeFilter = document.getElementById("filterType");
   const addBtn = document.getElementById("addRunBtn");
   if (!addBtn) return;
   function parseTime(t) {
       if (!t || !t.includes(":")) return 999999;
       const parts = t.split(":");
       return parseInt(parts[0]) * 60 + parseInt(parts[1]);
   }
   function sortAndRank() {
       const rows = Array.from(table.rows).slice(1);
       rows.sort((a, b) => {
           return parseTime(a.cells[6].innerText) - parseTime(b.cells[6].innerText);
       });
       rows.forEach(row => table.appendChild(row));
       rows.forEach((row, index) => {
           const rankCell = row.cells[0];
           if (index === 0) rankCell.innerHTML = "🥇 1";
           else if (index === 1) rankCell.innerHTML = "🥈 2";
           else if (index === 2) rankCell.innerHTML = "🥉 3";
           else rankCell.innerText = index + 1;
       });
   }
   function filterTable() {
       const selectedDungeon = dungeonFilter.value;
       const selectedType = typeFilter.value;
       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();

});