MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 59: | Line 59: | ||
Latest revision as of 19:33, 12 October 2026
/* Any JavaScript here will be loaded for all users on every page load. */
/* =========================
SHOW "CREATE PAGE" LINK ON MOBILE SEARCH
========================= */
mw.loader.using( 'mediawiki.util', function () {
// Run only on Special:Search
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'Search' ) {
return;
}
// Run only on mobile (Minerva)
if ( document.body.className.indexOf( 'skin-minerva' ) === -1 ) {
return;
}
// Find the "no results" message box
var noResultsBox = document.querySelector(
'.mw-search-results-none, .results-info, .mw-search-results'
);
if ( !noResultsBox ) {
return;
}
// Get search term
var searchInput = document.querySelector( 'input[type="search"], input[type="text"]' );
if ( !searchInput || !searchInput.value ) {
return;
}
var title = searchInput.value.trim().replace( /"/g, '' );
if ( !title ) {
return;
}
// Build create page URL
var createUrl = mw.util.getUrl( title, { action: 'edit', redlink: 1 } );
// Create link element
var link = document.createElement( 'p' );
link.className = 'mw-mobile-create-page';
link.innerHTML =
'Create the page "<strong>' + mw.html.escape( title ) +
'</strong>" on this wiki!';
link.style.marginTop = '12px';
link.style.fontSize = '16px';
// Make it clickable
link.onclick = function () {
window.location.href = createUrl;
};
noResultsBox.appendChild( link );
});
$(function () {
if (typeof window.adsbygoogle === 'undefined') {
return;
}
$('.marupedia-bio-ad ins.adsbygoogle').each(function () {
var ad = this;
if (ad.getAttribute('data-adsbygoogle-status')) {
return;
}
try {
(window.adsbygoogle = window.adsbygoogle || []).push({});
} catch (error) {
console.warn('MaruPedia AdSense error:', error);
}
});
});