MediaWiki:Common.js: Difference between revisions

From Hidden Mickey Wiki

No edit summary
Tags: Manual revert Reverted
No edit summary
Tag: Manual revert
Line 32: Line 32:
     $('#searchInput').css('width', '600px'); // Adjust width as needed
     $('#searchInput').css('width', '600px'); // Adjust width as needed
});
});
(function () {
  var box = document.createElement('div');
  box.id = 'mw-test-settings';
  box.style.position = 'absolute';
  box.style.top = '10px';
  box.style.right = '10px';
  box.style.background = 'white';
  box.style.border = '1px solid #ccc';
  box.style.padding = '4px';
  box.style.zIndex = 9999;
  var btn = document.createElement('button');
  btn.textContent = 'Settings ▾';
  var list = document.createElement('ul');
  list.style.listStyle = 'none';
  list.style.margin = '4px 0 0 0';
  list.style.padding = '0';
  list.style.display = 'none';
  ['Preferences', 'Watchlist'].forEach(function (txt) {
    var li = document.createElement('li');
    var a = document.createElement('a');
    a.textContent = txt;
    a.href = '/wiki/Special:' + txt;
    a.style.display = 'block';
    a.style.padding = '4px 8px';
    a.style.textDecoration = 'none';
    a.style.color = 'black';
    li.appendChild(a);
    list.appendChild(li);
  });
  btn.onclick = function () {
    list.style.display = (list.style.display === 'none') ? 'block' : 'none';
  };
  box.appendChild(btn);
  box.appendChild(list);
  document.body.appendChild(box);
})();

Revision as of 15:32, 18 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
});

(function () {
  var box = document.createElement('div');
  box.id = 'mw-test-settings';
  box.style.position = 'absolute';
  box.style.top = '10px';
  box.style.right = '10px';
  box.style.background = 'white';
  box.style.border = '1px solid #ccc';
  box.style.padding = '4px';
  box.style.zIndex = 9999;

  var btn = document.createElement('button');
  btn.textContent = 'Settings ▾';

  var list = document.createElement('ul');
  list.style.listStyle = 'none';
  list.style.margin = '4px 0 0 0';
  list.style.padding = '0';
  list.style.display = 'none';

  ['Preferences', 'Watchlist'].forEach(function (txt) {
    var li = document.createElement('li');
    var a = document.createElement('a');
    a.textContent = txt;
    a.href = '/wiki/Special:' + txt;
    a.style.display = 'block';
    a.style.padding = '4px 8px';
    a.style.textDecoration = 'none';
    a.style.color = 'black';
    li.appendChild(a);
    list.appendChild(li);
  });

  btn.onclick = function () {
    list.style.display = (list.style.display === 'none') ? 'block' : 'none';
  };

  box.appendChild(btn);
  box.appendChild(list);
  document.body.appendChild(box);
})();