Actions

MediaWiki

Common.js: Difference between revisions

From Dune Awakening DB

mNo edit summary
mNo edit summary
Line 1: Line 1:
// Image-based radial menu with 9 buttons (8 around + 1 center)
// MediaWiki Radial Menu with Custom Icons
$(document).ready(function() {
$(document).ready(function() {
   // Remove the "From Dune Awakening DB" tagline
   // Remove the "From Dune Awakening DB" tagline
Line 11: Line 11:
   });
   });
    
    
   // Create the radial menu structure with placeholder images
  // Define menu items with icon paths
   var radialMenuHTML = `
  const menuItems = [
    { id: "resources", name: "Resources", icon: "/images/ResourceNavIcon.png", position: "north" },
    { id: "crafting", name: "Crafting", icon: "/images/CraftingNavIcon.png", position: "northeast" },
    { id: "refining", name: "Refining", icon: "/images/RefiningNavIcon.png", position: "east" },
    { id: "vehicles", name: "Vehicles", icon: "/images/VehiclesNavIcon.png", position: "southeast" },
    { id: "armor", name: "Armor", icon: "/images/ArmorNavIcon.png", position: "south" },
    { id: "build", name: "Building", icon: "/images/BuildNavIcon.png", position: "southwest" },
    { id: "skills", name: "Skills", icon: "/images/SkillsNavIcon.png", position: "west" },
    { id: "technology", name: "Technology", icon: "/images/TechnologyNavIcon.png", position: "northwest" }
  ];
 
  // Create the center button HTML
  const centerButtonHTML = `
    <a href="/Main_Page" class="dune-radial-center">
      <img src="/images/QuestIconNav.png" alt="Home">
      <span class="dune-radial-tooltip">Home</span>
    </a>
  `;
 
   // Create the radial menu items HTML
  let radialItemsHTML = '';
  menuItems.forEach(item => {
    radialItemsHTML += `
      <a href="/${item.id}" class="dune-radial-item ${item.position}">
        <img src="${item.icon}" alt="${item.name}">
        <span class="dune-radial-tooltip">${item.name}</span>
      </a>
    `;
  });
 
  // Create the complete radial menu structure
   const radialMenuHTML = `
     <div id="duneRadialMenu" class="dune-radial-menu">
     <div id="duneRadialMenu" class="dune-radial-menu">
       <!-- Center button -->
       ${centerButtonHTML}
       <a href="/Main_Page" class="dune-radial-center">
       ${radialItemsHTML}
        <img src="https://dunedb.com/images/thumb/2/24/WikiPlaceholder.png/600px-WikiPlaceholder.png?20250401034151" alt="Home">
        <span class="dune-radial-tooltip">Home</span>
      </a>
     
      <!-- North button -->
      <a href="/Buildings" class="dune-radial-item north">
        <img src="https://dunedb.com/images/thumb/2/24/WikiPlaceholder.png/600px-WikiPlaceholder.png?20250401034151" alt="Buildings">
        <span class="dune-radial-tooltip">Buildings</span>
      </a>
     
      <!-- Northeast button -->
      <a href="/Items" class="dune-radial-item northeast">
        <img src="https://dunedb.com/images/thumb/2/24/WikiPlaceholder.png/600px-WikiPlaceholder.png?20250401034151" alt="Items">
        <span class="dune-radial-tooltip">Items</span>
      </a>
     
      <!-- East button -->
      <a href="/Crafting" class="dune-radial-item east">
        <img src="https://dunedb.com/images/thumb/2/24/WikiPlaceholder.png/600px-WikiPlaceholder.png?20250401034151" alt="Crafting">
        <span class="dune-radial-tooltip">Crafting</span>
      </a>
     
      <!-- Southeast button -->
      <a href="/Research" class="dune-radial-item southeast">
        <img src="https://dunedb.com/images/thumb/2/24/WikiPlaceholder.png/600px-WikiPlaceholder.png?20250401034151" alt="Research">
        <span class="dune-radial-tooltip">Research</span>
      </a>
     
      <!-- South button -->
      <a href="/Journeys" class="dune-radial-item south">
        <img src="https://dunedb.com/images/thumb/2/24/WikiPlaceholder.png/600px-WikiPlaceholder.png?20250401034151" alt="Journeys">
        <span class="dune-radial-tooltip">Journeys</span>
      </a>
     
      <!-- Southwest button -->
      <a href="/Vehicles" class="dune-radial-item southwest">
        <img src="https://dunedb.com/images/thumb/2/24/WikiPlaceholder.png/600px-WikiPlaceholder.png?20250401034151" alt="Vehicles">
        <span class="dune-radial-tooltip">Vehicles</span>
      </a>
     
      <!-- West button -->
      <a href="/Resources" class="dune-radial-item west">
        <img src="https://dunedb.com/images/thumb/2/24/WikiPlaceholder.png/600px-WikiPlaceholder.png?20250401034151" alt="Resources">
        <span class="dune-radial-tooltip">Resources</span>
      </a>
     
      <!-- Northwest button -->
      <a href="/Weapons" class="dune-radial-item northwest">
        <img src="https://dunedb.com/images/thumb/2/24/WikiPlaceholder.png/600px-WikiPlaceholder.png?20250401034151" alt="Weapons">
        <span class="dune-radial-tooltip">Weapons</span>
      </a>
     </div>
     </div>
     <div id="duneRadialOverlay" class="dune-radial-overlay"></div>
     <div id="duneRadialOverlay" class="dune-radial-overlay"></div>
Line 75: Line 55:
    
    
   // Create the logo container and breadcrumb
   // Create the logo container and breadcrumb
   var breadcrumbHTML = `
   const breadcrumbHTML = `
     <div class="dune-breadcrumb-nav">
     <div class="dune-breadcrumb-nav">
       <a id="duneLogoBtn" class="dune-logo-btn">
       <a id="duneLogoBtn" class="dune-logo-btn">
Line 93: Line 73:
   $('h1.firstHeading, .mw-page-title-main').parent().after(breadcrumbHTML);
   $('h1.firstHeading, .mw-page-title-main').parent().after(breadcrumbHTML);
    
    
   // Direct button click event
   // Opening animation effect
  const openMenu = () => {
    $('#duneRadialMenu').addClass('active');
    $('#duneRadialOverlay').addClass('active');
   
    // Add sequential animation to each item
    $('.dune-radial-item').each(function(index) {
      const $item = $(this);
      setTimeout(() => {
        $item.addClass('animated');
      }, index * 50);
    });
   
    // Animate center button last
    setTimeout(() => {
      $('.dune-radial-center').addClass('animated');
    }, menuItems.length * 50);
  };
 
  // Closing animation effect
  const closeMenu = () => {
    $('.dune-radial-item, .dune-radial-center').removeClass('animated');
   
    setTimeout(() => {
      $('#duneRadialMenu').removeClass('active');
      $('#duneRadialOverlay').removeClass('active');
    }, 300);
  };
 
  // Toggle menu when clicking the logo button
   $(document).on('click', '#duneLogoBtn', function(e) {
   $(document).on('click', '#duneLogoBtn', function(e) {
     e.preventDefault();
     e.preventDefault();
     e.stopPropagation();
     e.stopPropagation();
     $('#duneRadialMenu').toggleClass('active');
      
    $('#duneRadialOverlay').toggleClass('active');
    if ($('#duneRadialMenu').hasClass('active')) {
     console.log('Logo clicked'); // Debug output
      closeMenu();
     } else {
      openMenu();
    }
   });
   });
    
    
   // Close when clicking overlay
   // Close when clicking overlay
   $(document).on('click', '#duneRadialOverlay', function() {
   $(document).on('click', '#duneRadialOverlay', function() {
     $('#duneRadialMenu').removeClass('active');
     closeMenu();
     $('#duneRadialOverlay').removeClass('active');
  });
 
  // Close menu with ESC key
  $(document).on('keydown', function(e) {
     if (e.key === 'Escape' && $('#duneRadialMenu').hasClass('active')) {
      closeMenu();
    }
   });
   });
});
});

Revision as of 01:25, 7 April 2025

// MediaWiki Radial Menu with Custom Icons
$(document).ready(function() {
  // Remove the "From Dune Awakening DB" tagline
  $('#tagline').remove();
  
  // Reduce spacing above the title
  $('h1.title, .mw-page-title-main, h1.firstHeading').css({
    'margin-top': '0',
    'padding-top': '5px',
    'line-height': '1.2'
  });
  
  // Define menu items with icon paths
  const menuItems = [
    { id: "resources", name: "Resources", icon: "/images/ResourceNavIcon.png", position: "north" },
    { id: "crafting", name: "Crafting", icon: "/images/CraftingNavIcon.png", position: "northeast" },
    { id: "refining", name: "Refining", icon: "/images/RefiningNavIcon.png", position: "east" },
    { id: "vehicles", name: "Vehicles", icon: "/images/VehiclesNavIcon.png", position: "southeast" },
    { id: "armor", name: "Armor", icon: "/images/ArmorNavIcon.png", position: "south" },
    { id: "build", name: "Building", icon: "/images/BuildNavIcon.png", position: "southwest" },
    { id: "skills", name: "Skills", icon: "/images/SkillsNavIcon.png", position: "west" },
    { id: "technology", name: "Technology", icon: "/images/TechnologyNavIcon.png", position: "northwest" }
  ];
  
  // Create the center button HTML
  const centerButtonHTML = `
    <a href="/Main_Page" class="dune-radial-center">
      <img src="/images/QuestIconNav.png" alt="Home">
      <span class="dune-radial-tooltip">Home</span>
    </a>
  `;
  
  // Create the radial menu items HTML
  let radialItemsHTML = '';
  menuItems.forEach(item => {
    radialItemsHTML += `
      <a href="/${item.id}" class="dune-radial-item ${item.position}">
        <img src="${item.icon}" alt="${item.name}">
        <span class="dune-radial-tooltip">${item.name}</span>
      </a>
    `;
  });
  
  // Create the complete radial menu structure
  const radialMenuHTML = `
    <div id="duneRadialMenu" class="dune-radial-menu">
      ${centerButtonHTML}
      ${radialItemsHTML}
    </div>
    <div id="duneRadialOverlay" class="dune-radial-overlay"></div>
  `;
  
  // Add the menu to the page
  $('body').append(radialMenuHTML);
  
  // Create the logo container and breadcrumb
  const breadcrumbHTML = `
    <div class="dune-breadcrumb-nav">
      <a id="duneLogoBtn" class="dune-logo-btn">
        <img src="https://dunedb.com/favicon.ico" alt="DuneDB Logo" class="dune-logo">
      </a>
      <a href="/Main_Page">Home</a>
      <span class="dune-breadcrumb-separator">/</span>
      <a href="/Buildings">Buildings</a>
      <span class="dune-breadcrumb-separator">/</span>
      <a href="/Buildings/Refiners">Refiners</a>
      <span class="dune-breadcrumb-separator">/</span>
      <span>${$('h1.firstHeading').text() || $('.mw-page-title-main').text()}</span>
    </div>
  `;
  
  // Add the breadcrumb after the title
  $('h1.firstHeading, .mw-page-title-main').parent().after(breadcrumbHTML);
  
  // Opening animation effect
  const openMenu = () => {
    $('#duneRadialMenu').addClass('active');
    $('#duneRadialOverlay').addClass('active');
    
    // Add sequential animation to each item
    $('.dune-radial-item').each(function(index) {
      const $item = $(this);
      setTimeout(() => {
        $item.addClass('animated');
      }, index * 50);
    });
    
    // Animate center button last
    setTimeout(() => {
      $('.dune-radial-center').addClass('animated');
    }, menuItems.length * 50);
  };
  
  // Closing animation effect
  const closeMenu = () => {
    $('.dune-radial-item, .dune-radial-center').removeClass('animated');
    
    setTimeout(() => {
      $('#duneRadialMenu').removeClass('active');
      $('#duneRadialOverlay').removeClass('active');
    }, 300);
  };
  
  // Toggle menu when clicking the logo button
  $(document).on('click', '#duneLogoBtn', function(e) {
    e.preventDefault();
    e.stopPropagation();
    
    if ($('#duneRadialMenu').hasClass('active')) {
      closeMenu();
    } else {
      openMenu();
    }
  });
  
  // Close when clicking overlay
  $(document).on('click', '#duneRadialOverlay', function() {
    closeMenu();
  });
  
  // Close menu with ESC key
  $(document).on('keydown', function(e) {
    if (e.key === 'Escape' && $('#duneRadialMenu').hasClass('active')) {
      closeMenu();
    }
  });
});