Utente:Jalo/monobook.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Fine test
test DaniDF
Riga 1:
// <pre>
// Elenco dei tool da caricare.
 
var myButtons = new Array([2,'(',')','Parentesi tonde',0,''],[2,'===','===','Sottosezione (3)',0,''],[2,'====','====','Sottosezione (4)',0,''],[2,'{{subst:','}}','subst',0,''],[2,'{{Utente:DaniDF1995/Lab graf| ','}}~~~~','Laboratotio grafico',0,'File pronto'],[2,'[[#','|]]','Link episodi',0,''],[1,'{{avvisounicode}}','0','avvisounicode',0,'+ avvisounicode']);
var myButtons = new Array([2,'{{WIP|Jalo}}\\n{{UNESCO\\n|tipoBene = patrimonio\\n|nome = \\n|nomeInglese = \\n|immagine = \\n|anno = \\n|tipologia = Culturali\\n|pericolo= \\n|criterio = (i) (ii) (iii) (iv) (v) (vi) (vii) (viii) (ix) (x) (xi) (xii)\\n|link = \\n|stato = \\n|linkCategoria= \\n}}\\n','','UNESCO tpl',245,''],[2,'{{WIP|Jalo}}\\n{{coord||display=title}}\\n{{UNESCO\\n|tipoBene = patrimonio\\n|nome = \\n|nomeInglese = \\n|immagine = \\n|anno = \\n|tipologia = Culturali\\n|pericolo= \\n|criterio = (i) (ii) (iii) (iv) (v) (vi) (vii) (viii) (ix) (x) (xi) (xii)\\n|link = \\n|stato = \\n|linkCategoria= \\n}}\\n\\n\\n==Collegamenti esterni==\\n\\n*[http://whc.unesco.org/en/list/ Scheda UNESCO]\\n\\n{{Patrimoni Unesco|}}\\n\\n[[Categoria:Patrimoni dell\'umanità in ]]\\n','','UNESCO voce',0,''],[2,'{{Bio\\n|Titolo = \\n|Nome = \\n|Cognome = \\n|PostCognome = \\n|ForzaOrdinamento = \\n|Sesso = \\n|LuogoNascita = \\n|GiornoMeseNascita = \\n|AnnoNascita = \\n|LuogoMorte = \\n|LuogoMorteLink = \\n|GiornoMeseMorte = \\n|AnnoMorte = \\n|Attività = \\n|Nazionalità = \\n|PostNazionalità =\\n|Immagine = \\n|Didascalia =\\n|FineIncipit = \\n|Categorie = \\n}}','','Bio',315,''],[2,'{{Conflitto\\n|nome del conflitto = \\n|parte_di = \\n|immagine = \\n|didascalia = \\n|data = \\n|luogo = \\n|casus = \\n|mutamenti_territoriali = \\n|esito = \\n|schieramento1 = \\n|schieramento2 = \\n|comandante1 = [[Immagine:White flag icon.svg|16px]]\\n|comandante2 = \\n|effettivi1 = \\n|effettivi2 = \\n|perdite1 = \\n|perdite2 = \\n|perdite3 = \\n|note = \\n}}\\n{{Campagnabox conquista spagnola del Perù}}\\n{{Campagnabox Arauco}}\\n{{Campagnabox Guerra civile Inca}}\\n','','Conflitto',0,''],[2,'{{Box successione\\n|carica = \\n|immagine = \\n|periodo = \\n|precedente = \\n|successivo = \\n}}','','Box successione',92,'']);
 
var myLinks = new Array(['Voce su en.wiki','http://en.wikipedia.org/wiki/%TITOLO%'],['Voce su Commons','http://commons.wikimedia.org/wiki/Image:%TITOLO2%'],['Vecchio Edit-count','http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?user=Jalo&dbname=itwiki_p'],['Bold / No bold','javascript:bolda();'],['Logo / No logo','javascript:noLogo();']);
 
// Firefox
var toLoad = "purg led ns0 lks tabs mjs sand admin bot requi uec log whois unw allp wiki stu voto canc caut bpar edw wip sot small bar case fat nfat cwtch popup nms qed since edt vfol linkcomplete lrc elrc";
 
var nomeBot="JaloBot";
 
var toLoad = "lks wiki test benv cimm sot cne port avan cwtch nms qed dels popup lrc";
 
//Monobook Modulare
//Lancia il vero monobook
// Vedi [[Wikipedia:Monobook.js/MonobookCompleto.js]]
Riga 17 ⟶ 12:
document.writeln('<script type="text/javascript" src="/w/index.php?title=Wikipedia:Monobook.js/MonobookCompleto.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
popupFixRedirs=true;
//JUST FOR DEBUG
popupFixDabs=true;
//document.writeln('<script type="text/javascript" src="/w/index.php?title=Utente:Jalo/monobook.js/test&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
/**
 
* Ajoute des liens après les catégories pour rapidement
 
* supprimer / modifier / ajouter une catégorie sur un article.
//CONFIGURAZIONE POPUP
* Utilise Ajax et l'api MediaWiki pour rechercher une catégorie.
popupDelay = 2; // aspetta 2 secondi
* Version adaptée pour WP:fr de [[:commons:MediaWiki:HotCat.js]]
popupRedlinkRemoval = true; // elimina i collegamenti a link rossi
*
popupQueriedRevertSummary = "Rollback da popup. Ripristinata la versione di $3";
* Auteur original : Magnus Manske
popupRedlinkSummary = "Eliminato link rosso: %s";
* Adaptation pour WP:fr : Zelda
popupOnEditSelection = false;
* [[Catégorie:MediaWiki:Fonction Monobook en JavaScript]]
 
*/
//Mostra i Tatoo
document.writeln('<script type="text/javascript" src="/w/index.php?title=Utente:Jalo/Tatoo&action=raw&ctype=text/javascript&dontcountme=s"></script>');
// VARIABILI PERSONALIZZABILI
 
//TASTI PERSONALI
// Ritardo del suggerimento rispetto la digitazione del testo
addLoadEvent ( function ()
var hotcat_suggestion_delay = 0.1;
{
if (document.title.indexOf("Modifica") == -1)
// Dimensione della lista scorrevole (en items)
return;
var hotcat_list_size = 6;
addToolbarButton('tb-firma', 'javascript:addTextAtCursor("~~~~","","",4)',
'http://upload.wikimedia.org/wikipedia/commons/d/d1/Button_mysignature.png', 'My sign', 'Jalo');
// Numero massimo di categorie suggerite nella lista
 
var hotcat_list_items = 20;
addToolbarButton('tb-commento', 'javascript:addTextAtCursor("<!"+"--","Tolgo immagine inesistente","-->",0)',
'http://upload.wikimedia.org/wikipedia/commons/2/23/Quotes-Lithuanian.png', 'no-img', 'Tolgo immagine inesistente');
// Salvataggio automatico (senza bisogna di passare per la finestra di editing
 
var hotcat_autocommit = true;
daInserire = "==Cronologia precedente alla pulizia dai copyviol==\n{{cassetto\n|titolo=cronologia\n|testo=<pre>\n</pre>}}";
addToolbarButton('tb-cass', 'javascript:addText(daInserire, "Cronologia pre-pulizia copyviol", 1)',
// Permette di mostrare la lista dei suggerimenti verso il basso
'http://upload.wikimedia.org/wikipedia/commons/c/cd/Button_vote_deletion.png', '[pre-copyviol]', 'Cronologia pre-copyviol');
var hotcat_list_down = true;
});
 
// FINE DELLE VARIABILI PERSONALIZZABILI
//NASCONDI IL COPYWARN SOTTO LA CASELLA DI MODIFICA
addLoadEvent ( function ()
var hotcat_running = 0 ;
{
var hotcat_last_v = "" ;
if (document.getElementById("editpage-copywarn"))
var hotcat_exists_yes = "http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/P_yes.svg/20px-P_yes.svg.png" ;
document.getElementById("editpage-copywarn").style.display="none";
var hotcat_exists_no = "http://upload.wikimedia.org/wikipedia/commons/thumb/4/42/P_no.svg/20px-P_no.svg.png" ;
})
 
addOnloadHook ( hotcat ) ;
//Bolda il "wpTextbox1"
function bolda()
function hotcat () {
{
if ( hotcat_check_action() ) return ; // Edited page, reloading anyway
//Inverte BOLD/NO BOLD
var cookieExpire = new Date(); // scadenza del cookie
var catlinks = document.getElementById("catlinks");
cookieExpire.setTime(cookieExpire.getTime() + (30 * 24 * 60 * 60 * 1000)); // il cookie scade dopo un mese
 
if (! catlinks && wgNamespaceNumber %2 == 0) { // all except discussion
var boldare = GetCookie('wikiBolda');
// let's create a fake one
if (boldare == 'si')
var bodyC = document.getElementById("bodyContent");
SetCookie('wikiBolda', 'no', cookieExpire.toGMTString(), '/');
if (!bodyC) return;
else
catlinks = document.createElement("div");
SetCookie('wikiBolda', 'si', cookieExpire.toGMTString(), '/');
catlinks.id = "catlinks";
catlinks.appendChild(document.createElement("p"));
catlinks.firstChild.className = "catlinks";
bodyC.appendChild(catlinks);
}
var catline =
document.getElementById ('mw-normal-catlinks') ||
getElementsByClassName ( document , "p" , "catlinks" ) [0];
if ( catline == null || typeof catline == 'undefined' ) return ;
hotcat_modify_existing ( catline ) ;
hotcat_append_add_span ( catline ) ;
}
 
function hotcat_append_add_span ( catline ) {
if (wgAction == "edit")
var span_add = document.createElement ( "span" ) ;
addLoadEvent ( function ()
var span_sep = document.createTextNode ( " | " ) ;
{
if ( catline.firstChild ) catline.appendChild ( span_sep ) ;
var boldare = GetCookie('wikiBolda');
catline.appendChild ( span_add ) ;
if (boldare == 'si')
hotcat_create_span ( span_add ) ;
$("wpTextbox1").style.fontWeight = "bold";
})
 
//Nascondi il logo di wikipedia
function noLogo()
{
//Inverte LOGO/NO LOGO
var cookieExpire = new Date(); // scadenza del cookie
cookieExpire.setTime(cookieExpire.getTime() + (30 * 24 * 60 * 60 * 1000)); // il cookie scade dopo un mese
 
var nologo = GetCookie('wikiLogo');
if (nologo == 'si')
SetCookie('wikiLogo', 'no', cookieExpire.toGMTString(), '/');
else
SetCookie('wikiLogo', 'si', cookieExpire.toGMTString(), '/');
}
 
addLoadEventString.prototype.ucFirst (= function () {
return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
}
function hotcat_modify_span ( span , i ) {
var cat_title = span.firstChild.getAttribute ( "title" ) ;
// Removing leading Category:
cat_title = cat_title.substr(cat_title.indexOf(":") + 1);
var sep1 = document.createTextNode ( " " ) ;
var a1 = document.createTextNode ( "(-)" ) ;
var remove_link = document.createElement ( "a" ) ;
remove_link.href = "javascript:hotcat_remove(\"" + cat_title + "\");" ;
remove_link.appendChild ( a1 ) ;
span.appendChild ( sep1 ) ;
span.appendChild ( remove_link ) ;
var mod_id = "hotcat_modify_" + i ;
var sep2 = document.createTextNode ( " " ) ;
var a2 = document.createTextNode ( "(±)" ) ;
var modify_link = document.createElement ( "a" ) ;
modify_link.id = mod_id ;
modify_link.href = "javascript:hotcat_modify(\"" + mod_id + "\");" ;
modify_link.appendChild ( a2 ) ;
span.appendChild ( sep2 ) ;
span.appendChild ( modify_link ) ;
}
function hotcat_modify_existing ( catline ) {
var spans = catline.getElementsByTagName ( "span" ) ;
for ( var i = 0 ; i < spans.length ; i++ ) {
hotcat_modify_span ( spans[i] , i ) ;
}
}
function hotcat_remove ( cat_title ) {
var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
//if (window.confirm("Vuoi veramente eliminare la categoria '" + cat_title + "' ?")) tolto avviso per cancellazione categoria quando in autoconfirm
{
document.___location = editlk + '&hotcat_removecat=' + encodeURIComponent(cat_title) ;
var nologo = GetCookie('wikiLogo');
}
if (nologo == 'si')
$("p-logo").style.display = "none";
})
 
// TRADOTTO DA
function addTradottoDa()
{
enArticle = getpagecontent(wgTitle);
enArticle = enArticle.substr(enArticle.indexOf("[[en:")+5);
enArticle = enArticle.substr(0,enArticle.indexOf("]]"));
 
var my_date = new Date();
dataOggi = my_date.getDate()+" "+arrayMese[my_date.getMonth()+1]+" "+(1900+my_date.getYear());
addTextAtCursor("{{Tradotto da|en|"+enArticle+"|"+dataOggi+"|id}}\n~~"+"~~","+Tradotto da","",0);
}
 
// Configurazione HOTKEYS
var tastiHotkeys = new Array();
tastiHotkeys["firma"] = 'F';
tastiHotkeys["cate"] = 'C';
tastiHotkeys["obj"] = 'Z';
 
pulsantiComandoPers = new Array();
pulsantiHotkeyPers = new Array();
pulsantiDescrPers = new Array();
function hotcatGetParamValue(paramName, h) {
//PATRIMONIO
if (typeof h == 'undefined' ) { h = document.___location.href; }
pulsantiComandoPers["patrimonio"] = 'javascript:addTextAtCursor("[[patrimonio dell\'umanità|patrimoni dell\'umanità]]","","",50)';
var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
pulsantiHotkeyPers["patrimonio"] = 'P';
var m=cmdRe.exec(h);
pulsantiDescrPers["patrimonio"] = 'Patrimonio';
if (m) {
 
try {
//UNESCO
return decodeURIComponent(m[1]);
pulsantiComandoPers["unesco"] = 'javascript:addTextAtCursor("[[Organizzazione delle Nazioni Unite per l\'Educazione, la Scienza e la Cultura|UNESCO]]","","",87)';
} catch (someError) {}
pulsantiHotkeyPers["unesco"] = 'U';
}
pulsantiDescrPers["unesco"] = 'Unesco';
return null;
 
}
//SUP 2
pulsantiComandoPers["sup2"] = 'javascript:addTextAtCursor("²","","",1)';
function hotcat_check_action () {
pulsantiHotkeyPers["sup2"] = '2';
var ret = 0 ;
pulsantiDescrPers["sup2"] = 'Alla seconda';
if ( wgAction != "edit" ) return ret ; // Not an edit page, so no business...
 
var summary = new Array () ;
//CITA
var t = document.editform.wpTextbox1.value ;
pulsantiComandoPers["cita"] = 'javascript:addTextAtCursor("<ref>{{Cita||}}</ref>","","",12)';
var prevent_autocommit = 1 ;
pulsantiHotkeyPers["cita"] = 'R';
if ( typeof hotcat_autocommit != 'undefined' && hotcat_autocommit ) prevent_autocommit = 0 ;
pulsantiDescrPers["cita"] = '{{Cita}}';
 
// Remove existing category?
//PORTALE ANTICA ROMA
var hrc = hotcatGetParamValue('hotcat_removecat') ;
pulsantiComandoPers["roma"] = 'javascript:addTextAtCursor("{{Portale|Antica Roma|Germani|Storia}}","","",0)';
// Add new category?
pulsantiHotkeyPers["roma"] = 'A';
var hnc = hotcatGetParamValue('hotcat_newcat') ;
pulsantiDescrPers["roma"] = 'Portali';
 
if ( typeof hrc != "undefined" && hrc != null && hrc != "" ) {
//SOVRAIMMAGINE
var hcre = new RegExp("(\\s*)\\[\\[ *(?:Categoria|Category) *: *" + hrc.replace(/([\\\^\$\*\+\?\.\|\{\}\[\]\(\)])/g, "\\$1") + " *(\\|[^\\]]*)?\\]\\]", "gi");
pulsantiComandoPers["simm"] = 'javascript:addTextAtCursor("{{Sovraimmagine\\n | allineamento = right\\n | sotto = Germania Magna jpg.jpg\\n | sotto_larghezza = 300px\\n | sotto_didascalia = Mappa delle tribù germaniche (Nell ovale rosso gli Angrivari)\\n | sopra = Red oval.svg\\n | sopra_larghezza = 40px\\n | sopra_didascalia = Angrivari\\n | x = 80\\n | y = 55\\n}}","","",0)';
var matches = t.match(hcre);
pulsantiHotkeyPers["simm"] = 'S';
if (matches != null && matches.length == 1) { // Found one occurrence of the category - good!
pulsantiDescrPers["simm"] = 'Sovraimmagine';
if ( typeof hnc != "undefined" && hnc != null && hnc != "" ) {
 
t = t.replace(hcre, "$1[["+"Categoria:" + hnc + "$2]]");
//INTERPROGETTO
summary.push ( "Sostituita la categoria [["+"Categoria:" + hrc + "]] con [["+"Categoria:" + hnc + "]]" ) ;
pulsantiComandoPers["ipro2"] = 'javascript:addTextAtCursor("==Altri progetti==\\n\\n\\n\\n","","",20)';
} else {
pulsantiHotkeyPers["ipro2"] = 'I';
t = t.replace(hcre, "");
pulsantiDescrPers["ipro2"] = 'Interprogetto + titolo';
summary.push ( "Eliminata la categoria [["+"Categoria:" + hrc + "]]" ) ;
 
}
//CATEGORY:
ret = 1 ;
pulsantiComandoPers["category"] = 'javascript:addTextAtCursor("Category:","","",9)';
} else {
pulsantiHotkeyPers["category"] = 'X';
alert ( "Impossibile trovare il testo della \"" + hrc + "\" - la categoria potrebbe essere inclusa tramite template" ) ;
pulsantiDescrPers["category"] = 'Category:';
prevent_autocommit = 1 ;
 
}
//FOTO RICHIESTE:
} else {
pulsantiComandoPers["foto"] = 'javascript:addTextAtCursor("{{Richiesta"+" foto|}}","","",17)';
// Only adding?
pulsantiHotkeyPers["foto"] = 'N';
if ( typeof hnc != "undefined" && hnc != null && hnc != "" ) {
pulsantiDescrPers["foto"] = 'Richiesta foto';
// Looking for last cat
 
var re = /\[\[(?:Categoria|Category):[^\]]+\]\]/ig
//TRADOTTO DA:
var index = -1;
pulsantiComandoPers["mytradda"] = 'javascript:addTradottoDa()';
while (re.exec(t) != null) index = re.lastIndex;
pulsantiHotkeyPers["mytradda"] = 'T';
var txt = "[["+"Categoria:" + hnc + "]]" ;
pulsantiDescrPers["mytradda"] = 'Tradotto da';
if (index < 0) {
 
t = t + '\n' + txt ;
//CARICA IMMAGINE EDP:
} else {
pulsantiComandoPers["edp"] = 'javascript:$("wpUploadDescription").value=$("wpUploadDescription").value + "Foto di [[John Howland Rowe]], archeologo ed antropologo statunitense dell\'[[Università della California (Berkeley)]].\\n\\nL\'immagine è stata presa [http://www.mnsu.edu/emuseum/information/biography/pqrst/rowe_john_howland.html da questo sito] e i diritti sul suo sfruttamento sono di [http://www.universityofcalifornia.edu/senate/inmemoriam/johnhowlandrowe.htm].\\n\\nIl file va considerato accettabile per l\'[[Wikipedia:EDP per it.wiki|EDP]] in quanto la persona è morta.\\n\\n{{EDP}}"';
t = t.substring(0, index) + '\n' + txt + t.substring(index);
pulsantiHotkeyPers["edp"] = 'E';
}
pulsantiDescrPers["edp"] = 'Carica imamgine EDP';
summary.push ( "Aggiunta la categoria [["+"Categoria:" + hnc + "]]" ) ;
ret = 1 ;
}
}
if ( ret ) {
document.editform.wpTextbox1.value = t ;
document.editform.wpSummary.value = summary.join( " ; " ) + " (con [[MediaWiki:Gadget-HotCat.js|HotCat]])" ;
document.editform.wpMinoredit.checked = true ;
if ( !prevent_autocommit ) {
document.getElementById("bodyContent").style.display = "none" ; // Hiding the entire edit section so as not to tempt the user into editing...
document.editform.wpSave.click();
}
}
// This is the end, my friend, the end...
return ret ;
}
function hotcat_clear_span ( span_add ) {
while ( span_add.firstChild ) span_add.removeChild ( span_add.firstChild ) ;
}
function hotcat_create_span ( span_add ) {
hotcat_clear_span ( span_add ) ;
var a_add = document.createElement ( "a" ) ;
var a_text = document.createTextNode ( "(+)" ) ;
span_add.id = "hotcat_add" ;
a_add.href = "javascript:hotcat_add_new()" ;
a_add.appendChild ( a_text ) ;
span_add.appendChild ( a_add ) ;
}
function hotcat_modify ( link_id ) {
var link = document.getElementById ( link_id ) ;
var span = link.parentNode ;
var catname = span.firstChild.firstChild.data ;
while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ;
span.firstChild.style.display = "none" ;
hotcat_create_new_span ( span , catname ) ;
hotcat_last_v = "" ;
hotcat_text_changed () ; // Update icon
}
function hotcat_add_new () {
var span_add = document.getElementById ( "hotcat_add" ) ;
hotcat_clear_span ( span_add ) ;
hotcat_last_v = "" ;
hotcat_create_new_span ( span_add , "" ) ;
}
function hotcat_create_new_span ( thespan , init_text ) {
var form = document.createElement ( "form" ) ;
form.method = "post" ;
form.onsubmit = function () { hotcat_ok(); return false; } ;
form.id = "hotcat_form" ;
form.style.display = "inline" ;
var list = document.createElement ( "select" ) ;
list.id = "hotcat_list" ;
list.onclick = function () { document.getElementById("hotcat_text").value = document.getElementById("hotcat_list").value ; hotcat_text_changed() ; } ;
list.ondblclick = function () { document.getElementById("hotcat_text").value = document.getElementById("hotcat_list").value ; hotcat_text_changed() ; hotcat_ok(); } ;
list.style.display = "none" ;
var text = document.createElement ( "input" ) ;
text.size = 40 ;
text.id = "hotcat_text" ;
text.type = "text" ;
text.value = init_text ;
text.onkeyup = function () { window.setTimeout("hotcat_text_changed();", hotcat_suggestion_delay ); } ;
var exists = document.createElement ( "img" ) ;
exists.id = "hotcat_exists" ;
exists.src = hotcat_exists_no ;
var OK = document.createElement ( "input" ) ;
OK.type = "button" ;
OK.value = "OK" ;
OK.onclick = hotcat_ok ;
var cancel = document.createElement ( "input" ) ;
cancel.type = "button" ;
cancel.value = "Annulla" ;
cancel.onclick = hotcat_cancel ;
form.appendChild ( list ) ;
form.appendChild ( text ) ;
form.appendChild ( exists ) ;
form.appendChild ( OK ) ;
form.appendChild ( cancel ) ;
thespan.appendChild ( form ) ;
text.focus () ;
}
function hotcat_ok () {
var text = document.getElementById ( "hotcat_text" ) ;
var v = text.value ;
// Empty category ?
if ( v == "" ) {
hotcat_cancel() ;
return ;
}
var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
var url = editlk + '&hotcat_newcat=' + encodeURIComponent( v ) ;
// Editing existing?
var span = text.parentNode.parentNode ; // span.form.text
if ( span.id != "hotcat_add" ) { // Not plain "addition"
var cat_title = span.firstChild.getAttribute ( "title" ) ;
// Removing leading Category:
cat_title = cat_title.substr(cat_title.indexOf(":") + 1);
url += '&hotcat_removecat=' + encodeURIComponent( cat_title ) ;
}
document.___location = url ;
}
function hotcat_cancel () {
var span = document.getElementById("hotcat_form").parentNode ;
if ( span.id == "hotcat_add" ) {
hotcat_create_span ( span ) ;
} else {
while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ;
span.firstChild.style.display = "" ;
for ( var i = 0 ; i < span.parentNode.childNodes.length ; i++ ) {
if ( span.parentNode.childNodes[i] != span ) continue ;
hotcat_modify_span ( span , i ) ;
break ;
}
}
}
function hotcat_text_changed () {
if ( hotcat_running ) return ;
var text = document.getElementById ( "hotcat_text" ) ;
var v = text.value.ucFirst() ;
if ( hotcat_last_v == v ) return ; // Nothing's changed...
hotcat_running = 1 ;
hotcat_last_v = v ;
if ( v != "" ) {
var url = wgServer + wgScriptPath + "/api.php?format=xml&action=query&list=allpages&apnamespace=14&apfrom=" + encodeURIComponent( v ) + "&aplimit=" + encodeURIComponent( hotcat_list_items );
if ( typeof ( hotcat_xmlhttp ) != "undefined" ) hotcat_xmlhttp.abort() ; // Just to make sure...
hotcat_xmlhttp = new sajax_init_object() ;
hotcat_xmlhttp.open('GET', url, true);
hotcat_xmlhttp.onreadystatechange = function () {
if ( typeof hotcat_xmlhttp == "undefined" ) return ;
if (hotcat_xmlhttp.readyState == 4) {
var xml = hotcat_xmlhttp.responseXML ;
if ( xml == null ) return ;
var pages = xml.getElementsByTagName( "p" ) ;
var titles = new Array () ;
for ( var i = 0 ; i < pages.length ; i++ ) {
var s = pages[i].getAttribute("title");
// Removing leading "Category:"
s = s.substr(s.indexOf(":") + 1);
if ( s.substr ( 0 , hotcat_last_v.length ) != hotcat_last_v ) break ;
titles.push ( s ) ;
}
hotcat_show_suggestions ( titles ) ;
}
};
hotcat_xmlhttp.send(null);
} else {
var titles = new Array () ;
hotcat_show_suggestions ( titles ) ;
}
hotcat_running = 0 ;
}
function hotcat_show_suggestions ( titles ) {
var text = document.getElementById ( "hotcat_text" ) ;
var list = document.getElementById ( "hotcat_list" ) ;
var icon = document.getElementById ( "hotcat_exists" ) ;
if ( titles.length == 0 ) {
list.style.display = "none" ;
icon.src = hotcat_exists_no ;
return ;
}
var listh = hotcat_list_size * 20 ;
if (titles.length < hotcat_list_size) {
listh = titles.length * 20 ;
}
var nl = parseInt ( text.parentNode.offsetLeft ) - 1 ;
var nt = parseInt(text.offsetTop) - listh ;
// Parameter to show suggestion list beneath categories instead of above
if (typeof hotcat_list_down != "undefined" && hotcat_list_down) {
nt = text.offsetTop + text.offsetHeight;
}
list.size = 5 ;
list.style.align = "left" ;
list.style.zIndex = 5 ;
list.style.position = "absolute" ;
list.style.top = nt + "px" ;
list.style.width = text.offsetWidth + "px" ;
list.style.height = listh + "px" ;
list.style.left = nl + "px" ;
while ( list.firstChild ) list.removeChild ( list.firstChild ) ;
for ( var i = 0 ; i < titles.length ; i++ ) {
var opt = document.createElement ( "option" ) ;
var ot = document.createTextNode ( titles[i] ) ;
opt.appendChild ( ot ) ;
opt.setAttribute( "value", titles[i] );
list.appendChild ( opt ) ;
}
list.style.display = "block" ;
icon.src = hotcat_exists_yes ;
var first_title = titles.shift () ;
if ( first_title == hotcat_last_v ) return ;
var suggestion = first_title;
text.value = suggestion ;
if (text.createTextRange) {
// IE
var ra = text.createTextRange();
ra.moveStart("character", hotcat_last_v.length);
ra.moveEnd("character", suggestion.length);
ra.select();
} else if( is_khtml ) {
text.setSelectionRange( hotcat_last_v.length, suggestion.length );
} else {
text.selectionStart = hotcat_last_v.length ;
text.selectionEnd = suggestion.length ;
}
}
 
// </pre>