MediaWiki:Gadget-common-special-search.js
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.
/* Copied from [[w:ru:MediaWiki:Gadget-common-special-search.js]], designed by [[User:Jack who built the house]] */
/* Used in the [[MediaWiki:Search-summary]] */
mw.hook( 'wikipage.content' ).add( function () {
// Table of keywords for searching: link the handler to the "Keywords" link,
// add. design, make keywords clickable
( function () {
var $pseudolinkWrapper = $( '#keywords-popup-pseudolink-wrapper' );
var $popup = $( '#keywords-popup' );
var popupShownFirstTime = true;
$pseudolinkWrapper.show().find( 'a' ).removeAttr( 'title' )
.click( function ( e ) {
e.preventDefault();
// Use the [[mw:Extension:Popups]] classes (work even when disabled
// pop-up windows)
if ( !$popup.hasClass( 'mwe-popups-fade-in-up' ) ) {
$popup
.show()
.removeClass( 'mwe-popups-fade-out-down' )
.addClass( 'mwe-popups-fade-in-up' );
if ( popupShownFirstTime ) {
// Position the "tail" of the popup box
var popupTailPart1Left = $pseudolinkWrapper.offset().left + ( $pseudolinkWrapper.width() / 2 ) -
$popup.offset().left;
$( '#keywords-popup-tail-part1' ).css( 'left', popupTailPart1Left + 'px' );
$( '#keywords-popup-tail-part2' ).css( 'left', ( popupTailPart1Left - 3 ) + 'px' );
}
popupShownFirstTime = false;
} else {
$popup
.removeClass( 'mwe-popups-fade-in-up' )
.addClass( 'mwe-popups-fade-out-down' );
setTimeout( function () {
// The status has not changed: the "Keywords" link has not been clicked
// in the middle of attenuation
if ( $popup.hasClass( 'mwe-popups-fade-out-down' ) ) {
$popup.hide();
}
}, 150 );
}
} );
$popup.find( 'a' ).attr( 'target', '_blank' );
var messageCompleteHelp = $( '#keywords-popup-message-completeHelp' ).text();
$( '#mw-indicator-mw-helplink a' ).text( messageCompleteHelp );
var messageInsertKeyword = $( '#keywords-popup-message-insertKeyword' ).text();
var $searchBox = $( '#searchText input' );
$( '.keywords-popup-keyword' ).wrap( $( '<a>' )
.attr( 'href', 'javascript:;' )
.attr( 'title', messageInsertKeyword )
.click( function( e ) {
e.preventDefault();
$searchBox.val( $searchBox.val() + $( this ).find( '.keywords-popup-keyword' )
.data( 'keyword' ).replace( / /g, ' ' ) ).focus();
} )
);
}() );
/*
// Remove [[MediaWiki:Searchmenu-new]] if searching with "prefix:" (usually in talk archives)
var cL = $( '.mw-search-createlink' );
if ( / prefix:/.test( cL.find( 'a:first' ).text() ) )
cL.after( '<br>' ).remove();
// External search engines
var searchInput = document.querySelector( '#searchText input' );
var list = {
'Google': 'https://google.com/search?q=%s+site:ru.wikipedia.org&hl=ru',
'Яндексе': 'https://yandex.ru/yandsearch?text=%s&site=ru.wikipedia.org',
'Bing': 'https://www.bing.com/search?q=%s+site:ru.wikipedia.org',
};
var listKeys = Object.keys( list );
var searchEngines = document.createElement( 'p' );
searchEngines.id = 'searchEngines';
searchEngines.innerHTML = 'Искать в (';
searchEngines.style.float = 'right';
for ( var i in list ) {
var link = document.createElement( 'a' );
link.href = list[ i ].replace( '%s', searchInput.value );
link.textContent = i;
searchEngines.appendChild( link );
if ( listKeys.indexOf( i ) < listKeys.length - 1 ) {
searchEngines.appendChild( document.createTextNode( ' | ' ) );
}
}
searchEngines.appendChild(document.createTextNode( ')' ));
$( '.searchresults > .mw-search-visualclear:not(.mw-search-interwiki-header)' ).after( searchEngines );
*/
} );