MediaWiki:Tierlist.js

From Roat Pkz
Revision as of 09:10, 18 July 2026 by Hefner (talk | contribs)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
mw.loader.using('mediawiki.util').then(function () {

    console.log("✅ TierList.js loaded");

    let draggedItem = null;

    document.querySelectorAll(".tier-item").forEach(function(item) {

        item.draggable = true;

        item.addEventListener("dragstart", function() {
            draggedItem = item;
            console.log("Dragging:", item.id);
        });

    });


    document.querySelectorAll(".tier-items").forEach(function(container) {

        container.addEventListener("dragover", function(e) {
            e.preventDefault();
        });


        container.addEventListener("drop", function(e) {
            e.preventDefault();

            if (draggedItem) {
                container.appendChild(draggedItem);
                console.log("Dropped:", draggedItem.id);
            }

        });

    });

});