Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
// Test if JavaScript is loading
console.log('MediaWiki:Common.js is loaded!');
// Wait for the document to be fully ready
jQuery(function($) {
// Check if the button exists on the page
var button = document.getElementById('trigger-citizen-search');
if (!button) {
console.log('Search button not found.');
return;
}
// Add the click event listener
button.addEventListener('click', function() {
console.log('Search button was clicked!'); // Check if this appears in console
// Try multiple possible selectors for the Citizen search trigger
var selectors = [
'#citizen-search-details summary',
'.citizen-search-trigger',
'.citizen-search__button',
'[title*="earch"]' // Matches elements with "search" in the title
];
var triggerClicked = false;
for (var i = 0; i < selectors.length; i++) {
var element = document.querySelector(selectors[i]);
if (element) {
console.log('Found trigger with selector:', selectors[i]);
element.click();
triggerClicked = true;
break; // Stop after the first successful click
}
}
// Fallback if no trigger was found
if (!triggerClicked) {
console.log('No search trigger found. Falling back to search page.');
window.location.href = mw.config.get('wgScriptPath') + '/Special:Search';
}
});
});