MediaWiki:Common.js: Difference between revisions

From Hidden Mickey Wiki

No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 35: Line 35:
/* Menu in the NavBar */
/* Menu in the NavBar */
/* This puts up a Test Menu */
/* This puts up a Test Menu */
/* $(document).ready(function() {
$(document).ready(function() {
   var logo = document.getElementById('p-logo');
   var logo = document.getElementById('p-logo');
   if (logo) {
   if (logo) {
     logo.parentNode.insertAdjacentHTML('afterend', '<div class="test-menu">Test Menu Styled</div>');
     logo.parentNode.insertAdjacentHTML('afterend', '<div class="test-menu">Test Menu Styled</div>');
  }
}); */
$(document).ready(function() {
  var logo = document.getElementById('p-logo');
  if (logo) {
    logo.parentNode.insertAdjacentHTML('afterend', `
      <div class="dropdown" style="display:inline-block; margin-left: 10px;">
        <button onclick="toggleDropdown()" class="dropbtn">Menu ▼</button>
        <div id="myDropdownContent" class="dropdown-content">
          <a href="/Page1">Page 1</a>
          <a href="/Page2">Page 2</a>
          <a href="/Page3">Page 3</a>
        </div>
      </div>
    `);
   }
   }
});
});

Revision as of 14:14, 16 September 2025

/* Any JavaScript here will be loaded for all users on every page load. */
// JavaScript code to save checkbox state and restore it when the page loads
$(document).ready(function() {
    // Function to save the state of checkboxes to localStorage
    function saveCheckboxState() {
        $('input[type="checkbox"]').each(function() {
            localStorage.setItem($(this).attr('id'), $(this).prop('checked'));
        });
    }

    // Function to load the state of checkboxes from localStorage
    function loadCheckboxState() {
        $('input[type="checkbox"]').each(function() {
            const savedState = localStorage.getItem($(this).attr('id'));
            if (savedState !== null) {
                $(this).prop('checked', savedState === 'true');
            }
        });
    }

    // Load the saved checkbox state when the page is loaded
    loadCheckboxState();

    // Save the checkbox state whenever a checkbox is changed
    $('input[type="checkbox"]').change(function() {
        saveCheckboxState();
    });
});

// Adjust the search box width
$(document).ready(function () {
    $('#searchInput').css('width', '600px'); // Adjust width as needed
});

/* Menu in the NavBar */
/* This puts up a Test Menu */
$(document).ready(function() {
  var logo = document.getElementById('p-logo');
  if (logo) {
    logo.parentNode.insertAdjacentHTML('afterend', '<div class="test-menu">Test Menu Styled</div>');
  }
});