تضامنًا مع حق الشعب الفلسطيني |
ميدياويكي:Gadget-SearchEngines.js
اذهب إلى التنقل
اذهب إلى البحث
ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.
//[[fr:MediaWiki:Gadget-ExternalSearch.js]]
/* globals mw, $ */
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ) {
mw.loader.using( 'mediawiki.util', function () {
'use strict';
var searchbox;
function externalSearchEngines( $ ) {
var $searchbox = $( '#searchText' ).find( 'input' );
if ( !$searchbox.length ) {
return;
}
searchbox = $searchbox[ 0 ];
var language = 'ar';
var domain = mw.config.get( 'wgServer' ).replace( /^.*?\/\//, '' );
var colorExternal = $( '<a class="external">' )
.wrap( '<div class="mw-parser-output">' )
.css( 'color' );
var $choices = $( '<div>' );
$choices.css( {
'clear': 'right',
'padding-top': '0.5em'
} );
$choices.append( '<b>المصادر العربية:</b> ' );
var space = '';
searchEngines.forEach( function ( engine ) {
if ( space ) {
$choices.append( space );
}
space = ' • ';
var $a = $( '<a>' );
$a.text( engine.Name );
$a.attr( 'target', '_blank' );
$a.css( 'color', colorExternal );
$choices.append( $a );
// préparsage des templates, pour avoir ça de moins à exécuter lors des events "text input"
engine.HomePage = engine.HomePage
.split( '{language}' ).join( language )
.split( '{domain}' ).join( domain );
engine.Template = engine.Template
.split( '{language}' ).join( language )
.split( '{domain}' ).join( domain );
engine.Element = $a[ 0 ];
} );
updateHrefs();
$searchbox.on( 'input', mw.util.debounce( 100, updateHrefs ) );
$choices.insertAfter( '#mw-search-top-table' );
}
function updateHrefs() {
var searchTerms = searchbox.value;
if ( searchTerms === '' ) {
searchEngines.forEach( function ( engine ) {
engine.Element.href = engine.HomePage;
} );
} else {
searchEngines.forEach( function ( engine ) {
engine.Element.href = engine.Template.split( '{searchTerms}' ).join( searchTerms );
} );
}
}
var searchEngines = [
{
Name: 'الشاملة',
HomePage: 'https://www.google.com/search?hl={language}&q=site:shamela.ws ',
Template: 'https://www.google.com/search?hl={language}&q=site:shamela.ws "{searchTerms}"'
},
{
Name: 'كتب جوجل',
HomePage: 'https://www.google.com/search?hl={language}&tbm=bks',
Template: 'https://www.google.com/search?hl={language}&tbm=bks&q={searchTerms}'
},
{
Name: 'جوجل',
HomePage: 'https://www.google.com/search?hl={language}',
Template: 'https://www.google.com/search?hl={language}&q={searchTerms}'
},
{
Name: 'بينغ',
HomePage: 'https://www.bing.com/search?setlang={language}',
Template: 'https://www.bing.com/search?setlang={language}&q={searchTerms}'
},
{
Name: 'الأنطولوجيا',
HomePage: 'https://ontology.birzeit.edu/',
Template: 'https://ontology.birzeit.edu/term/{searchTerms}'
},
{
Name: 'المعجم التاريخي',
HomePage: 'https://www.dohadictionary.org/',
Template: 'https://www.dohadictionary.org/dictionary/{searchTerms}'
},
{
Name: 'المكتبة العربية',
HomePage: 'https://duckduckgo.com/?q=site:arablib.com ',
Template: 'https://duckduckgo.com/?q=site:arablib.com {searchTerms}'
},
{
Name: 'مساحة',
HomePage: 'https://www.google.com/search?hl={language}&q=site:www.masaha.org/research/book/ ',
Template: 'https://www.google.com/search?hl={language}&q=site:www.masaha.org/research/book/ {searchTerms}'
}
];
$( externalSearchEngines );
} );
}