MediaWiki:Common.js

From Ragnafied Wiki

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.
$(document).ready(function() {
    // 1. Create floating menu (Included your new items)
    var menuHTML = `
        <div class="floating-menu" id="floatingMenu">
            <div class="floating-menu-header" id="menuHeader">
                <span>๐Ÿ“‹ QUICK NAV</span>
                <span class="arrow">โ–ผ</span>
            </div>
            <div class="floating-menu-items">
                <a href="/index.php/Main_Page">๐Ÿ  Main Page</a>
                <a href="/index.php/First_Steps">๐Ÿš€ First Steps</a>
                <a href="/index.php/VIP">๐Ÿ‘‘ VIP</a>
                <a href="/index.php/Enchant_Stones">๐Ÿ’Ž Enchant Stones</a>
                <a href="/index.php/Nyangvines">๐Ÿฑ Nyangvines</a>
                <a href="/index.php/Custom_Systems">โš™๏ธ Custom Systems</a>
                <a href="/index.php/Monthly_Kachua">๐Ÿ“… Monthly Kachua</a>
                <a href="/index.php/Troubleshooting">๐Ÿ”ง Troubleshooting</a>
                <a href="/index.php/Card_Trader_and_Kachua_Tokens">๐Ÿƒ Card and Tokens</a>
                <a href="/index.php/Equipment_Enhancement">๐Ÿ›ก๏ธ EQ Enhancement</a>
            </div>
        </div>
        <div class="floating-menu-toggle" id="menuToggle">โ˜ฐ</div>
    `;
    
    $('body').append(menuHTML);

    // 2. ACTIVE PAGE HIGHLIGHTING
    // This finds which link matches the current URL and adds an 'active' class
    var currentPath = window.location.pathname;
    $('.floating-menu-items a').each(function() {
        if ($(this).attr('href') === currentPath) {
            $(this).addClass('active-link').css({
                "background": "rgba(255, 106, 0, 0.1)",
                "border-left": "3px solid #FF6A00",
                "font-weight": "bold"
            });
        }
    });

    // 3. HIDE ON SCROLL (Desktop only)
    var lastScrollTop = 0;
    $(window).scroll(function() {
        if ($(window).width() > 768) {
            var st = $(this).scrollTop();
            if (st > lastScrollTop && st > 300) {
                // Scrolling down - Hide
                $('#floatingMenu').css('right', '-200px');
            } else {
                // Scrolling up - Show
                $('#floatingMenu').css('right', '20px');
            }
            lastScrollTop = st;
        }
    });

    // --- Original Functionality ---
    $('#menuHeader').click(function() {
        $('#floatingMenu').toggleClass('collapsed');
    });
    
    $('#menuToggle').click(function() {
        $('#floatingMenu').toggleClass('mobile-visible');
    });
    
    $(document).click(function(event) {
        if ($(window).width() <= 768) {
            if (!$(event.target).closest('#floatingMenu, #menuToggle').length) {
                $('#floatingMenu').removeClass('mobile-visible');
            }
        }
    });
});