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 | ||
}); | |||
$(document).ready(function () { | |||
// Create the dropdown menu | |||
var customDropdown = $('<div>', { class: 'custom-dropdown mw-portlet', id: 'p-custom-menu' }); | |||
var dropdownLabel = $('<h3>', { class: 'vector-menu-heading' }).text('Custom Menu'); | |||
var dropdownList = $('<ul>', { class: 'vector-menu-content-list' }); | |||
// Add menu items | |||
var menuItems = [ | |||
{ text: 'Item 1', href: '/wiki/Page1' }, | |||
{ text: 'Item 2', href: '/wiki/Page2' }, | |||
{ text: 'Item 3', href: '/wiki/Page3' } | |||
]; | |||
menuItems.forEach(function (item) { | |||
var listItem = $('<li>'); | |||
var link = $('<a>', { href: item.href }).text(item.text); | |||
listItem.append(link); | |||
dropdownList.append(listItem); | |||
}); | |||
// Append elements | |||
customDropdown.append(dropdownLabel).append(dropdownList); | |||
$('#p-tb').after(customDropdown); // Place it next to Tools menu | |||
}); | }); | ||
Revision as of 23:42, 11 March 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
});
$(document).ready(function () {
// Create the dropdown menu
var customDropdown = $('<div>', { class: 'custom-dropdown mw-portlet', id: 'p-custom-menu' });
var dropdownLabel = $('<h3>', { class: 'vector-menu-heading' }).text('Custom Menu');
var dropdownList = $('<ul>', { class: 'vector-menu-content-list' });
// Add menu items
var menuItems = [
{ text: 'Item 1', href: '/wiki/Page1' },
{ text: 'Item 2', href: '/wiki/Page2' },
{ text: 'Item 3', href: '/wiki/Page3' }
];
menuItems.forEach(function (item) {
var listItem = $('<li>');
var link = $('<a>', { href: item.href }).text(item.text);
listItem.append(link);
dropdownList.append(listItem);
});
// Append elements
customDropdown.append(dropdownLabel).append(dropdownList);
$('#p-tb').after(customDropdown); // Place it next to Tools menu
});