Utente:Sanjilops/monobook.js: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
Contenuto aggiunto Contenuto cancellato
mNessun oggetto della modifica |
Nessun oggetto della modifica |
||
Riga 13: | Riga 13: | ||
if (wgPageName == "Utente:Sanjilops/sandbox") gif_hack(); |
if (wgPageName == "Utente:Sanjilops/sandbox") gif_hack(); |
||
disable_search_thumb = true; |
|||
//search_thumb___(); |
|||
/* Funzioni dell'editor */ |
/* Funzioni dell'editor */ |
||
Riga 227: | Riga 229: | ||
return; |
return; |
||
} |
} |
||
} |
|||
/* Mostra thumbnail delle immagini nella ricerca */ |
|||
function search_thumb___() { |
|||
if (wgPageName != "Speciale:Ricerca") return false; |
|||
var list = getElementsByClass(document, 'mw-search-results-title', 'a'); |
|||
for (var i = 0; i < list.length; i++) { |
|||
if (/^File:/i.test(getText(list[i])) && /\.(gif|ico|jpeg|jpg|png|svg)$/i.test(getText(list[i]))) addThumb(list[i], getText(list[i])); |
|||
} |
|||
return; |
|||
function addThumb (link, file) { |
|||
var httpRequest = createRequest(); |
|||
var id = setTimeout(function() { httpRequest.abort();}, 30000); |
|||
httpRequest.onreadystatechange = function () { Do(httpRequest, id, link, file); return; } |
|||
httpRequest.open('GET', wgServer + wgScriptPath + "/api.php?action=imagethumb&format=xml&tiwidth=50&tiimage=" + encodeURIComponent(file.replace(/^File:/i, '')), true); |
|||
httpRequest.send(''); |
|||
return; |
|||
} |
|||
function Do(o, id, link, file) { |
|||
if (o.readyState != 4) return; |
|||
clearTimeout(id); |
|||
if (o.status != 200) return; |
|||
if (o.responseXML == null) return; |
|||
if (o.responseXML.normalize) o.responseXML.normalize(); |
|||
if (o.responseXML.getElementsByTagName('thumb')[0] == undefined) return false; |
|||
var url = o.responseXML.getElementsByTagName('thumb')[0].getAttribute("url"); |
|||
if (url == null) return false; |
|||
var img = document.createElement('img'); |
|||
img.src = url; |
|||
img.alt = file; |
|||
img.width = o.responseXML.getElementsByTagName('thumb')[0].getAttribute("width"); |
|||
img.height = o.responseXML.getElementsByTagName('thumb')[0].getAttribute("height"); |
|||
img.style.marginRight = "3px"; |
|||
link.insertBefore(img, link.firstChild); |
|||
return; |
|||
} |
|||
} |
} |