User:Cizagna/filelisttools.js

//See user page for more info. if( wgNamespaceNumber == -1 && wgCanonicalSpecialPageName=='Listfiles' && !window.IListButtonsLoaded ) addOnloadHook( addImageListButtons ); var IListButtonsLoaded = true; // prevent duplication

function addImageListButtons { switch( skin ) { case 'answers': case 'awesome': case 'monaco_old': case 'monaco': $(' Show images (full)').appendTo('#page_controls'); $(' how images (small)').appendTo('#page_controls'); $(' Desc links only').appendTo('#page_controls'); break;

case 'uncyclopedia': case 'wowwiki': case 'lostbook': case 'monobook': $('Show images (full)').appendTo('#p-cactions > .pBody > ul'); $('Show images (small)</li>').appendTo('#p-cactions > .pBody > ul'); $('<a href="javascript:filelistprune" title="turns the whole page into just a list of links">Desc links only</a></li>').appendTo('#p-cactions > .pBody > ul'); break;

} }

function showFLimages(full) { var links = document.getElementById('bodyContent').getElementsByTagName('a'); var img; if(wgUserLanguage=='es') var fileLang='archivo'; else var fileLang='file'; for(var i=0;i < links.length;i++) { if(links[i].firstChild.nodeValue==fileLang) { links[i].firstChild.nodeValue = ''; links[i].parentNode.setAttribute('class','plainlinks'); img = document.createElement('img'); img.setAttribute('src',links[i].href); if(full==0) { img.setAttribute('style','border:2px outset blue;'); } else { img.setAttribute('style','width:200px;height:200px;border:2px outset blue;'); }			links[i].appendChild(img); }	}	document.getElementById('ca-showim0').style.display='none'; document.getElementById('ca-showim1').style.display='none'; document.getElementById('ca-prune').style.display='none'; // not compatible with filelistprune }

function filelistprune { var descs = getElementsByClassName(document,'td','TablePager_col_img_name'); var dlist = ' '; for(var i=0;i < descs.length;i++) { dlist += '<a href="' + descs[i].firstChild.href + '">' + descs[i].firstChild.title + '</a>\n'; }	dlist += ' \n'; document.getElementById('bodyContent').innerHTML = dlist; document.getElementById('ca-showim0').style.display='none'; // not compatible with showFLimages document.getElementById('ca-showim1').style.display='none'; // not compatible with showFLimages document.getElementById('ca-prune').style.display='none'; }