MediaWiki:Search.js: различия между версиями
Материал из ЕЖЕВИКИ - EJWiki.org - Академической Вики-энциклопедии по еврейским и израильским темам
Перейти к навигацииПерейти к поиску
Ariely (обсуждение | вклад) Нет описания правки |
Ariely (обсуждение | вклад) Нет описания правки |
||
| Строка 4: | Строка 4: | ||
'Поиск в Википедии': 'http://ru.wikiwix.com/?action=%s&disp=article', | 'Поиск в Википедии': 'http://ru.wikiwix.com/?action=%s&disp=article', | ||
'Google': 'http://www.google.com/custom?q=%s&hl=ru&domains=www.ejwiki.org;pubs.ejwiki.org&sitesearch=.ejwiki.org', | 'Google': 'http://www.google.com/custom?q=%s&hl=ru&domains=www.ejwiki.org;pubs.ejwiki.org&sitesearch=.ejwiki.org', | ||
'Yahoo': 'http://search.yahoo.com/search?p=%s&vs= | 'Yahoo': 'http://search.yahoo.com/search?p=%s&vs=www.ejwiki.org', | ||
'Яндекс': 'http://yandex.ru/yandsearch?text=%s&site= | 'Яндекс': 'http://yandex.ru/yandsearch?text=%s&site=www.ejwiki.org&site_manually=true&ras=1' | ||
} | } | ||
createOption = function(site, engine) { | createOption = function(site, engine) { | ||
| Строка 13: | Строка 13: | ||
return opt | return opt | ||
} | } | ||
var searchForm = document.forms['search'] || document.forms['powersearch'] | var searchForm = document.forms['search'] || document.forms['powersearch'] || document.forms['searchform'] | ||
if (searchForm.fulltext) searchForm.fulltext.value = 'Найти' | if (searchForm.fulltext) searchForm.fulltext.value = 'Найти' | ||
submit = function() { | submit = function() { | ||
Текущая версия от 05:59, 20 апреля 2010
function searchPage() {
var searchEngines = {
'Внутренний поиск': false,
'Поиск в Википедии': 'http://ru.wikiwix.com/?action=%s&disp=article',
'Google': 'http://www.google.com/custom?q=%s&hl=ru&domains=www.ejwiki.org;pubs.ejwiki.org&sitesearch=.ejwiki.org',
'Yahoo': 'http://search.yahoo.com/search?p=%s&vs=www.ejwiki.org',
'Яндекс': 'http://yandex.ru/yandsearch?text=%s&site=www.ejwiki.org&site_manually=true&ras=1'
}
createOption = function(site, engine) {
var opt = document.createElement('option')
opt.appendChild(document.createTextNode(site))
opt.value = site
return opt
}
var searchForm = document.forms['search'] || document.forms['powersearch'] || document.forms['searchform']
if (searchForm.fulltext) searchForm.fulltext.value = 'Найти'
submit = function() {
var optSelected = searchEngines[document.getElementById('searchEngine').value]
if (optSelected) {
searchInput = document.getElementById('searchText') || document.getElementById('powerSearchText')
window.location = optSelected.replace(/%s/g, encodeURIComponent(searchInput.value))
return false
}
}
if (navigator.appName == 'Microsoft Internet Explorer') addHandler(searchForm, 'submit', submit)
else searchForm.onsubmit = submit
var selectBox = document.createElement('select')
selectBox.id = 'searchEngine'
for (var se in searchEngines)
selectBox.appendChild(createOption(se, searchEngines[se]))
searchInput = document.getElementById('searchText') || document.getElementById('powerSearchText')
searchInput.parentNode.insertBefore(selectBox, searchInput.nextSibling)
}
addOnloadHook(searchPage)