MediaWiki:Common.js: Difference between revisions
From Hidden Mickey Wiki
No edit summary Tag: Manual revert |
No edit summary Tag: Reverted |
||
| Line 31: | Line 31: | ||
$(document).ready(function () { | $(document).ready(function () { | ||
$('#searchInput').css('width', '600px'); // Adjust width as needed | $('#searchInput').css('width', '600px'); // Adjust width as needed | ||
}); | |||
/* === SIMPLE DROPDOWN TEST === */ | |||
$(function () { | |||
// Create container | |||
var $box = $('<div id="mw-simple-settings"></div>'); | |||
var $btn = $('<button>Settings ▾</button>'); | |||
var $ul = $('<ul></ul>'); | |||
// Add 2 test links | |||
$ul.append('<li><a href="/wiki/Special:Preferences">Preferences</a></li>'); | |||
$ul.append('<li><a href="/wiki/Special:Watchlist">Watchlist</a></li>'); | |||
$box.append($btn).append($ul); | |||
// Put it at top of body (so it's visible no matter the skin) | |||
$('body').append($box); | |||
// Toggle menu | |||
$btn.on('click', function () { | |||
$ul.toggle(); | |||
}); | |||
}); | }); | ||
Revision as of 15:20, 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
});
/* === SIMPLE DROPDOWN TEST === */
$(function () {
// Create container
var $box = $('<div id="mw-simple-settings"></div>');
var $btn = $('<button>Settings ▾</button>');
var $ul = $('<ul></ul>');
// Add 2 test links
$ul.append('<li><a href="/wiki/Special:Preferences">Preferences</a></li>');
$ul.append('<li><a href="/wiki/Special:Watchlist">Watchlist</a></li>');
$box.append($btn).append($ul);
// Put it at top of body (so it's visible no matter the skin)
$('body').append($box);
// Toggle menu
$btn.on('click', function () {
$ul.toggle();
});
});