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 { addTabForXSkin('ca-showim0','javascript:showFLimages(0)','loads the images in a full sized image tag','Show images (full)') addTabForXSkin('ca-showim1','javascript:showFLimages(1)','loads the images in a 200x200 image tag','Show images (small)') addTabForXSkin('ca-prune','javascript:filelistprune','turns the whole page into just a list of links','Desc links only') }

function showFLimages(full) { $( 'td.#TablePager_col_thumb').empty

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 += '' + descs[i].firstChild.title + '\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'; }