3482
правки
Изменения
Нет описания правки
/* Test if an element has a certain class **************************************
* * From English Wikipedia, 2008-09-15
* * Description: Uses regular expressions and caching for better performance.
* Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
*/
var hasClass = (function() {
var reCache = {};
return function( element, className ) {
return ( reCache[className] ? reCache[className] : ( reCache[className] = new RegExp( "(?:\\s|^)" + className + "(?:\\s|$)" ) ) ).test( element.className );
};
})();
/* Выпадающий список внешнего поиска на странице поиска */
function externalSearchEngines() {
var list = {
'Внутренний поиск': '',
'Google': 'google.com/search?q=!+site:psylab.info&hl=ru',
'Яндекс': 'yandex.ru/yandsearch?text=!&site=psylab.info'
}
var sel = ''
for( var nm in list )
sel += '<option value="' + list[nm] + '">' + nm + '</option>'
var frm = $('#search, #powersearch').eq(0),
inp = frm.find('input[name=search]')
$( '<select id=searchEngines>' + sel + '</select>' ).insertAfter( inp )
frm.submit(function(e){
var site = $('#searchEngines').val()
if( !site ) return true
e.preventDefault()
window.location = 'http://' + site.replace(/!/, encodeURIComponent( inp.val() ) )
return false
})
}
$( externalSearchEngines )