MediaWiki:Gadget-externalsearch.js
Giao diện
Chú ý: Sau khi lưu thay đổi trang, bạn phải xóa bộ nhớ đệm của trình duyệt để nhìn thấy các thay đổi. Google Chrome, Firefox, Internet Explorer và Safari: Giữ phím ⇧ Shift và nhấn nút Reload/Tải lại trên thanh công cụ của trình duyệt. Để biết chi tiết và hướng dẫn cho các trình duyệt khác, xem Trợ giúp:Xóa bộ nhớ đệm.
/** Thay Đặc biệt:Tìm kiếm thành trình đơn thả xuống **************************************************** * * Miêu tả: Thay Đặc biệt:Tìm kiếm thành trình đơn thả xuống, mặc định là bộ tìm kiếm * bên trong của MediaWiki * Khởi tạo và bảo trì: [[User:Gracenotes]] */function SpecialSearchEnhanced() { var createOption = function(site, action, mainQ, addQ, addV) { var opt = document.createElement('option'); opt.appendChild(document.createTextNode(site)); window.searchEngines.push([action, mainQ, addQ, addV]); return opt; } if (document.forms.powersearch) var searchForm = document.forms.powersearch; if (document.forms.search) var searchForm = document.forms.search; if (searchForm.lsearchbox) { var searchBox = searchForm.lsearchbox; } else { var searchBox = searchForm.search; } var selectBox = document.createElement('select'); selectBox.id = 'searchEngine'; searchForm.onsubmit = function() { var optSelected = window.searchEngines[document.getElementById('searchEngine').selectedIndex]; searchForm.action = optSelected[0]; searchBox.name = optSelected[1]; searchForm.title.value = optSelected[3]; searchForm.title.name = optSelected[2]; } selectBox.appendChild(createOption('Wiki Scholarship', mw.config.get( 'wgScript' ), 'search', 'title', 'Đặc_biệt:Tìm_kiếm')); selectBox.appendChild(createOption('Google', '//www.google.com/search', 'q', 'sitesearch', 'vi.wikipedia.org')); selectBox.appendChild(createOption('Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'vi.wikipedia.org')); selectBox.appendChild(createOption('Bing', 'http://www.bing.com/search', 'q', 'q1', 'site:http://vi.wikipedia.org')); selectBox.appendChild(createOption('Wikiwix', 'http://www.wikiwix.com/', 'action', 'lang', 'vi')); selectBox.appendChild(createOption('Exalead', 'http://www.exalead.com/wikipedia/results', 'q', 'language', 'vi')); searchBox.style.marginLeft = '0px'; if (document.getElementById('loadStatus')) { var lStat = document.getElementById('loadStatus'); } else { var lStat = searchForm.title; if( typeof lStat === 'object' && typeof lStat.length === 'number' ) lStat = lStat[0]; } lStat.parentNode.insertBefore(selectBox, lStat);}window.searchEngines = [];// Script is specific to Special:Searchif ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search'){ $(SpecialSearchEnhanced);}