MediaWiki:Search.js

From Wiki
Revision as of 14:14, 13 February 2013 by Sancho (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Note: After saving, 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: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
function searchPage() {
 var searchEngines = {
//  'Внутренний поиск': false,
//  'Wikiwix': 'http://ru.wikiwix.com/?action=%s&disp=article',
  'Яndex': 'http://yandex.ru/yandsearch?text=%s&site=wiki.harlamenkov.ru&site_manually=true&ras=1',
//  'Yahoo': 'http://search.yahoo.com/search?p=%s&vs=ru.wikipedia.org',
  'Google': 'http://www.google.ru/custom?q=%s&hl=ru&domains=wiki.harlamenkov.ru&sitesearch=wiki.harlamenkov.ru'
  }
 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']
 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)