User:TheFearow/suggest.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:TheFearow/suggest. |
/*
author: Inez Korczynski ( lastname at gmail dot com ) Modifications by TheFearow from en.wikipedia.org
*/
function dw($s) {
document.write($s);
}
dw("\<script");
dw(" src='http://developer.yahoo.com/yui/build/yahoo/yahoo-min.js'");
dw("\>\</script\>");
dw("\<script");
dw(" src='http://developer.yahoo.com/yui/build/dom/dom-min.js'");
dw("\>\</script\>");
dw("\<script");
dw(" src='http://developer.yahoo.com/yui/build/event/event-min.js'");
dw("\>\</script\>");
dw("\<script");
dw(" src='http://developer.yahoo.com/yui/build/animation/animation.js'");
dw("\>\</script\>");
dw("\<script");
dw(" src='http://developer.yahoo.com/yui/build/connection/connection-min.js'");
dw("\>\</script\>");
dw("\<script");
dw(" src='http://developer.yahoo.com/yui/build/autocomplete/autocomplete.js'");
dw("\>\</script\>");
dw("\<link rel=\"stylesheet\" type=\"text/css\"");
dw(" href='http://images.wikia.com/central/suggest/suggest.css'");
dw("/\>");
var nsShowed = false;
var sExpand = false;
function initSuggest() {
if(skin != 'monobook') {
return; // currently that script works only with monobook skin
}
if(!YAHOO.util.Dom.get('searchInput') || !YAHOO.util.Dom.get('searchGoButton')) {
return; // missing HTML elements
}
var suggestDiv = document.createElement('div');
suggestDiv.id = 'searchSuggest';
YAHOO.util.Dom.get('searchInput').parentNode.insertBefore(suggestDiv, YAHOO.util.Dom.get('searchGoButton'));
YAHOO.example.SuggestFunction = new function(){
this.oDS = new YAHOO.widget.DS_XHR(wgScriptPath + "/api.php", ["query.allpages","title"]);
this.oDS.scriptQueryAppend = "action=query&list=allpages&format=json";
this.oDS.scriptQueryParam = "apfrom";
this.oDS.queryMatchCase = false;
this.oDS.queryMatchContains = true;
this.oAutoComp = new YAHOO.widget.AutoComplete('searchInput', 'searchSuggest', this.oDS);
this.oAutoComp.autoHighlight = false;
this.oAutoComp.typeAhead = true;
this.oAutoComp.queryDelay = 0;
this.oAutoComp.doBeforeSendQuery = function(sQuery){
if(sQuery.indexOf('%20') > 0 ) {
sQuery = sQuery.replace("%20", "_");
}
sExpand = true;
return sQuery.charAt(0).toUpperCase() + sQuery.substr(1);
}
this.oAutoComp.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults ) {
return sExpand;
}
};
}
addOnloadHook(initSuggest);
//window.onload = initSuggest;