ميدياويكى:Common.js/search.js
ملحوظه: بعد التسييف، ممكن تحتاج تفضى كاش البراوزر بتاعك عشان تشوف التغييرات اللى عملتها، بالطريقه دى:
- فايرفوكس وسفارى: دوس ⇧ Shift مع Reload او Ctrl-F5 او Ctrl-R (اللى هو: Command-R على ماكنتوش)
- جوجل كروم: دوس Ctrl-Shift-R (اللى هو: Command-Shift-R على ماكنتوش)
- انترنت اكسبلورر: دوس Ctrl مع Refresh فى نفس الوقت، او Ctrl-F5
- كونكرر: دوس Reload او F5
- اوبرا: فضى الكاش من Tools → Preferences
/** Change Special:Search to use a radio menu *******************************************************
*
* Description: Change Special:Search to use a radio menu, with the default being
* the internal MediaWiki engine
* Created and maintained by: [[:fr:User:Pmartin]]
*/
if (mw.config.get('wgNamespaceNumber') == -1 && mw.config.get('wgCanonicalSpecialPageName') == "Search") {
var searchEngines = {
mediawiki: {
ShortName: 'تدوير فى ميدياويكى' ,
Template: "/w/index.php?search={searchTerms}"
},
google: {
ShortName: 'جوجل',
Template: "http://www.google.fr/search?hl=" + mw.config.get('wgUserLanguage') + "&q={searchTerms}&as_sitesearch=" + mw.config.get('wgServer').substr(7, mw.config.get('wgServer').length - 1 )
},
wikiwix: {
ShortName: 'ويكى وكس',
Template: "http://www.wikiwix.com/index.php?action={searchTerms}&lang="+mw.config.get('wgContentLanguage')
},
yahoo: {
ShortName: 'ياهو',
Template: "http://" + mw.config.get('wgUserLanguage') + ".search.yahoo.com/search?p={searchTerms}&vs=" + mw.config.get('wgServer')
}
};
jQuery( document ).ready(externalSearchEngines);
}
function externalSearchEngines() {
if (typeof SpecialSearchEnhanced2Disabled != 'undefined') return;
var mainNode = document.getElementById("powersearch");
if (!mainNode) mainNode = document.getElementById("search");
if (!mainNode) return;
var beforeNode = document.getElementById("mw-search-top-table");
if (!beforeNode) return;
beforeNode = beforeNode.nextSibling;
if (!beforeNode) return;
var firstEngine = "mediawiki";
var choices = document.createElement("div");
choices.setAttribute("id","searchengineChoices");
choices.style.textAlign = "center";
var lsearchbox = document.getElementById("searchText");
var initValue = lsearchbox.value;
var space = "";
for (var id in searchEngines) {
var engine = searchEngines[id];
if(engine.ShortName)
{
if (space) choices.appendChild(space);
space = document.createTextNode(" ");
var attr = {
type: "radio",
name: "searchengineselect",
value: id,
onFocus: "changeSearchEngine(this.value)",
id: "searchengineRadio-"+id
};
var html = "<input";
for (var a in attr) html += " " + a + "='" + attr[a] + "'";
html += " />";
var span = document.createElement("span");
span.innerHTML = html;
choices.appendChild( span );
var label
if (engine.Template.indexOf('http') == 0) {
label = document.createElement("a");
label.href = engine.Template.replace("{searchTerms}", initValue).replace("{language}", "fr");
} else {
label = document.createElement("label");
}
label.appendChild( document.createTextNode( engine.ShortName ) );
choices.appendChild( label );
}
}
mainNode.insertBefore(choices, beforeNode);
var input = document.createElement("input");
input.id = "searchengineextraparam";
input.type = "hidden";
mainNode.insertBefore(input, beforeNode);
changeSearchEngine(firstEngine, initValue);
}
function changeSearchEngine(selectedId, searchTerms) {
var currentId = document.getElementById("searchengineChoices").currentChoice;
if (selectedId == currentId) return;
document.getElementById("searchengineChoices").currentChoice = selectedId;
var radio = document.getElementById('searchengineRadio-' + selectedId);
radio.checked = "checked";
var engine = searchEngines[selectedId];
var p = engine.Template.indexOf('?');
var params = engine.Template.substr(p+1);
var form;
if (document.forms["search"]) {
form = document.forms["search"];
} else {
form = document.getElementById("powersearch");
}
form.setAttribute("action", engine.Template.substr(0,p));
var l = ("" + params).split("&");
for (var idx = 0;idx < l.length;idx++) {
var p = l[idx].split("=");
var pValue = p[1];
if (pValue == "{language}") {
} else if (pValue == "{searchTerms}") {
var input;
input = document.getElementById("searchText");
input.name = p[0];
} else {
var input = document.getElementById("searchengineextraparam");
input.name = p[0];
input.value = pValue;
}
}
}
//jQuery( document ).ready(SpecialSearchEnhanced);