MediaWiki:Searchlist.js
Вы находитесь на сайте "Архив статей из ЭЕЭ и статей на еврейские темы из Википедии"
(Различия между версиями)
Ariely (Обсуждение | вклад) (Новая страница: «function searchList(){ if (!window.searchListInNewWin) searchListInNewWin = false var newWinOption var msgThisWin, msgNewWin = 'в НОВОМ окне', msgSelectT…») |
Ariely (Обсуждение | вклад) |
||
(6 промежуточных версий не показаны.) | |||
Строка 10: | Строка 10: | ||
[-5,'в этом окне', 'переключатель, показывать ли результат в новом окне'], | [-5,'в этом окне', 'переключатель, показывать ли результат в новом окне'], | ||
['','Внешний поиск'], | ['','Внешний поиск'], | ||
- | ['http://www.google.com/custom?hl=ru&domains= | + | ['http://www.google.com/custom?hl=ru&domains=ejwiki.org&sitesearch=ejwiki.org&q=', 'Google→Ежевика', 'Google.ru по Ежевике'], |
- | ['http://www.google.com/custom?hl=ru&domains=ru.wikipedia.org&sitesearch=ru.wikipedia.org&q=', ' | + | ['http://www.yandex.ru/yandsearch?site=http://www.ejwiki.org&site_manually=true&ras=1&text=','Yandex→Ежевика', 'Yandex.ru по Ежевике'], |
- | ['http:// | + | ['http://www.google.com/custom?hl=ru&domains=ru.wikipedia.org&sitesearch=ru.wikipedia.org&q=', 'Google→Википедия', 'Google.ru по русской Википедии'], |
+ | ['http://images.google.ru/images?hl=ru&sitesearch=wikimedia.org&q=', 'Google→Картинки', 'поиск изображений на Викискладе'], | ||
['','MediaWiki'], | ['','MediaWiki'], | ||
[-1,'По умолчанию'], | [-1,'По умолчанию'], | ||
[0,'Статьи'], | [0,'Статьи'], | ||
- | [ | + | [6,'Изображения'], |
+ | [14,'Категории'], | ||
+ | [10,'Шаблоны'], | ||
[2,'Участник'], | [2,'Участник'], | ||
+ | [4,'Ежевика'], | ||
+ | [1,'Статьи (обс)'], | ||
[3,'Участник (обс)'], | [3,'Участник (обс)'], | ||
- | + | [5,'Ежевика (обс)'], | |
- | [5,' | + | [8,'MediaWiki'] |
- | + | ||
- | + | ||
- | [8,' | + | |
- | + | ||
- | + | ||
- | + | ||
] | ] | ||
if (!window.searchListShortNS) | if (!window.searchListShortNS) | ||
Строка 74: | Строка 73: | ||
searchForm.fulltext.parentNode.insertBefore(select, searchHidden) | searchForm.fulltext.parentNode.insertBefore(select, searchHidden) | ||
//hide standard Search button if not IE //if (is_opera || is_gecko){ | //hide standard Search button if not IE //if (is_opera || is_gecko){ | ||
- | if (navigator.userAgent.indexOf('MSIE') == -1){ | + | //if (navigator.userAgent.indexOf('MSIE') == -1){ |
- | + | // searchForm.fulltext.style.display = 'none' | |
- | + | // searchForm.go.title = searchForm.go.value | |
- | + | // searchForm.go.value = ' → ' | |
- | + | // searchForm.go.style.width = '30px' | |
- | + | // select.style.width = '90px' | |
- | } | + | //} |
select.title = msgSelectTitle | select.title = msgSelectTitle | ||
searchForm.go.title += ' (' + (is_gecko||is_safari?'Ctrl':'Shift') + ': ' + msgNewWin + ')' | searchForm.go.title += ' (' + (is_gecko||is_safari?'Ctrl':'Shift') + ': ' + msgNewWin + ')' |
Текущая версия на 05:08, 4 апреля 2010
function searchList(){ if (!window.searchListInNewWin) searchListInNewWin = false var newWinOption var msgThisWin, msgNewWin = 'в НОВОМ окне', msgSelectTitle = 'выберите пространство для поиска' if (!window.searchListNS) searchListNS = [ ['','найти в…'], [-5,'в этом окне', 'переключатель, показывать ли результат в новом окне'], ['','Внешний поиск'], ['http://www.google.com/custom?hl=ru&domains=ejwiki.org&sitesearch=ejwiki.org&q=', 'Google→Ежевика', 'Google.ru по Ежевике'], ['http://www.yandex.ru/yandsearch?site=http://www.ejwiki.org&site_manually=true&ras=1&text=','Yandex→Ежевика', 'Yandex.ru по Ежевике'], ['http://www.google.com/custom?hl=ru&domains=ru.wikipedia.org&sitesearch=ru.wikipedia.org&q=', 'Google→Википедия', 'Google.ru по русской Википедии'], ['http://images.google.ru/images?hl=ru&sitesearch=wikimedia.org&q=', 'Google→Картинки', 'поиск изображений на Викискладе'], ['','MediaWiki'], [-1,'По умолчанию'], [0,'Статьи'], [6,'Изображения'], [14,'Категории'], [10,'Шаблоны'], [2,'Участник'], [4,'Ежевика'], [1,'Статьи (обс)'], [3,'Участник (обс)'], [5,'Ежевика (обс)'], [8,'MediaWiki'] ] if (!window.searchListShortNS) searchListShortNS = { 'u':'User', 'i':'Image', 't':'Template', 'c':'Category', 'me':'MediaWiki', 'wp':'Project', 'у':'Участник', 'и':'Изображение', 'к':'Категория', 'ш':'Шаблон', 'п':'Портал' } var searchForm = document.getElementById('searchform') if (!searchForm) return //create namespace selector hidden input var searchHidden = document.createElement('input') searchHidden.type = 'hidden' searchHidden.value = '1' searchForm.fulltext.parentNode.appendChild(searchHidden) //create select var select = document.createElement('select'), item, opt, text for (var i=0; i<searchListNS.length; i++){ item = searchListNS[i] opt = new Option(item[1], item[0]) opt.title = item[2] || '' if (i == 0) opt.style.color = '#222222' else if (opt.value == -5){ newWinOption = opt msgThisWin = opt.text }else if (opt.value == ''){ opt.disabled = true opt.style.color = 'gray' opt.style.paddingLeft = '10px' }else opt.txt = ' ' + opt.txt select.options[select.options.length] = opt } //select.selectedIndex = 0 with (select.style){ margin = '0'; marginTop = '2px'; fontSize = '90%'} setTarget() searchForm.fulltext.parentNode.insertBefore(select, searchHidden) //hide standard Search button if not IE //if (is_opera || is_gecko){ //if (navigator.userAgent.indexOf('MSIE') == -1){ // searchForm.fulltext.style.display = 'none' // searchForm.go.title = searchForm.go.value // searchForm.go.value = ' → ' // searchForm.go.style.width = '30px' // select.style.width = '90px' //} select.title = msgSelectTitle searchForm.go.title += ' (' + (is_gecko||is_safari?'Ctrl':'Shift') + ': ' + msgNewWin + ')' //events addHandler(searchForm.search, 'keydown', detectShift) //if Enter pressed addHandler(searchForm.go, 'mouseup', detectShift) //Go clicked select.onchange = onSelect //addHandler(select, 'click', detectShift) addHandler(searchForm, 'submit', shortNS) return function detectShift(e){ //open in new win if shift is pressed e = e || window.event searchForm.target = (searchListInNewWin || e.shiftKey || (is_gecko||is_safari) && e.ctrlKey) ? '_blank' : '' } function onSelect(e){ if (this.selectedIndex == 0 || this.options[this.selectedIndex].disabled){ this.selectedIndex = 0 return } var val = this.options[this.selectedIndex].value this.selectedIndex = 0 if (! /^-?\d+$/.test(val)){ //not a number => external search engine var url = val + encodeURIComponent(searchForm.search.value) if (searchListInNewWin) window.open(url) else window.location = url }else if (val == -5){ //new window switch searchListInNewWin = !searchListInNewWin setTarget() }else if (searchForm.search.value == ''){ searchForm.search.value = '?' }else { //MediaWiki search searchHidden.name = (val == -1) ? '' : 'ns' + val detectShift(e) //doesn't work in FF/Safari anyway searchForm.fulltext.click() } } function setTarget(){ searchForm.target = searchListInNewWin ? '_blank' : '' select.style.backgroundColor = searchListInNewWin ? '#F5F5FF' : '' newWinOption.text = ' (' + (searchListInNewWin ? msgNewWin : msgThisWin) + ')' } function shortNS(){ //expands 'u:test' into 'User:test' var txt = searchForm.search.value, k if ((k=txt.indexOf(':'))==-1 || txt.substring(0,1) == ' ') return var pref = txt.substring(0,k).toLowerCase() if (searchListShortNS[pref]) searchForm.search.value = searchListShortNS[pref] + txt.substring(k) return true } }//searchList func if (doneOnloadHook)searchList() else addOnloadHook(searchList)