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 14: | Riga 14: | ||
if (wgPageName == "Utente:Sanjilops/sandbox") gif_hack(); |
if (wgPageName == "Utente:Sanjilops/sandbox") gif_hack(); |
||
disable_search_thumb = true; |
disable_search_thumb = true; |
||
search_fix(); |
|||
search_thumb___(); |
|||
/* Funzioni dell'editor */ |
/* Funzioni dell'editor */ |
||
Riga 233: | Riga 233: | ||
/* Mostra thumbnail delle immagini nella ricerca */ |
/* Mostra thumbnail delle immagini nella ricerca */ |
||
function |
function search_fix() { |
||
if (wgPageName != "Speciale:Ricerca") return false; |
if (wgPageName != "Speciale:Ricerca") return false; |
||
var |
var links = getElementsByClass(document, 'mw-search-result-title', 'a'); |
||
var titles = new Array(), |
var titles = new Array(), image_titles = new Array(), image_links = new Array(); |
||
for (var i = 0; i < |
for (var i = 0; i < links.length; i++) { |
||
titles.push(getText(links[i])); |
|||
if (/^File:/i.test(getText(list[i])) && /\.(gif|ico|jpeg|jpg|png|svg)$/i.test(getText(list[i]))) { |
|||
if (/^File:/i.test(getText(links[i]))) { |
|||
image_titles.push(getText(links[i])); |
|||
image_links.push(links[i]); |
|||
} |
} |
||
} |
} |
||
var httpRequest = createRequest(); |
var httpRequest = createRequest(); |
||
httpRequest.onreadystatechange = function () { Do(httpRequest, id |
httpRequest.onreadystatechange = function () { Do(httpRequest, id); return; } |
||
var param = "format=xml&action=query&prop= |
var param = "format=xml&action=query&prop=info%7" + "Cimageinfo&iiprop=url&iiurlwidth=50&titles=" + encodeURIComponent(titles.join('|')); |
||
httpRequest.open('POST', wgServer + wgScriptPath + "/api.php", true); |
httpRequest.open('POST', wgServer + wgScriptPath + "/api.php", true); |
||
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); |
||
Riga 253: | Riga 254: | ||
return; |
return; |
||
function Do(o, id |
function Do(o, id) { |
||
if (o.readyState != 4) return; |
if (o.readyState != 4) return; |
||
clearTimeout(id); |
clearTimeout(id); |
||
Riga 263: | Riga 264: | ||
var url = '', ii, img, l; |
var url = '', ii, img, l; |
||
for (var i = 0; i < page.length; i++) { |
for (var i = 0; i < page.length; i++) { |
||
l = |
l = titles.indexOf(page[i].getAttribute('title')); |
||
if (l == -1) continue; |
if (l == -1) continue; |
||
/* rimuove risultati eliminati */ |
|||
if (page[i].getAttribute('missing') != undefined) { |
if (page[i].getAttribute('missing') != undefined) { |
||
links[l].style.color = "rgb(50, 50, 50)"; |
links[l].style.color = "rgb(50, 50, 50)"; |
||
links[l].style.textDecoration = "line-through"; |
links[l].style.textDecoration = "line-through"; |
||
links[l]. |
links[l].style.fontSize = "50%"; |
||
links[l].title = links[l].title + " (pagina inesistente)"; |
|||
getElementsByClass(document, 'searchresult', 'div')[l].style.display = 'none'; |
|||
continue; |
continue; |
||
} |
} |
||
/* anteprima immagini */ |
|||
if (page[i].getAttribute('ns') != '6') continue; |
|||
ii = page[i].getElementsByTagName('ii')[0]; |
ii = page[i].getElementsByTagName('ii')[0]; |
||
if (ii == undefined) continue; |
if (ii == undefined) continue; |
||
if (ii.getAttribute("thumbheight") == '-1') continue; // non è un'immagine |
|||
url = ii.getAttribute("thumburl"); |
url = ii.getAttribute("thumburl"); |
||
if (url == null) continue; |
if (url == null) continue; |
||
img = document.createElement('img'); |
img = document.createElement('img'); |
||
img.src = url; |
img.src = url; |
||
img.alt = |
img.alt = ''; |
||
img.width = ii.getAttribute("thumbwidth"); |
img.width = ii.getAttribute("thumbwidth"); |
||
img.height = ii.getAttribute("thumbheight"); |
img.height = ii.getAttribute("thumbheight"); |
||
img.style.marginRight = "3px"; |
img.style.marginRight = "3px"; |
||
l = image_titles.indexOf(page[i].getAttribute('title')); |
|||
image_links[l].insertBefore(img, image_links[l].firstChild); |
|||
} |
} |
||
return; |
return; |