MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Created page with "→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; } // F..." |
No edit summary |
||
| Line 56: | Line 56: | ||
noResultsBox.appendChild( link ); | noResultsBox.appendChild( link ); | ||
}); | |||
mw.loader.using('mediawiki.util').then(function () { | |||
$(document).ready(function () { | |||
// Banner load करने के लिए div | |||
var banner = '<div id="promo-banner-bottom" style="margin-top:30px;"></div>'; | |||
// पूरा content select करो | |||
var content = document.querySelector('#mw-content-text'); | |||
if (content) { | |||
// content के end में add करो | |||
content.insertAdjacentHTML('beforeend', banner); | |||
// Template load करो | |||
$('#promo-banner-bottom').load('/index.php?title=Template:PromotionBanner&action=render'); | |||
} | |||
}); | |||
}); | }); | ||
Revision as of 12:47, 25 April 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 );
});
mw.loader.using('mediawiki.util').then(function () {
$(document).ready(function () {
// Banner load करने के लिए div
var banner = '<div id="promo-banner-bottom" style="margin-top:30px;"></div>';
// पूरा content select करो
var content = document.querySelector('#mw-content-text');
if (content) {
// content के end में add करो
content.insertAdjacentHTML('beforeend', banner);
// Template load करो
$('#promo-banner-bottom').load('/index.php?title=Template:PromotionBanner&action=render');
}
});
});