User:Sannse/Imagelisttools.js

if (wgPageName == 'Special:Imagelist') { $(imagelistTools); }

function imagelistTools { addPortletLink('p-cactions', 'javascript:showFLimages(0)', 'Show images (full)', 'ca-showim0', 'loads the images in a full sized image tag'); addPortletLink('p-cactions', 'javascript:showFLimages(1)', 'Show images (small)', 'ca-showim1', 'loads the images in a 200x200 image tag'); addPortletLink('p-cactions', 'javascript:filelistprune', 'Desc links only', 'ca-prune', 'turns the whole page into just a list of links'); }

function showFLimages(full) { var links = document.getElementById('bodyContent').getElementsByTagName('a'); var img; for (var i = 0; i < links.length; i++) { if (links[i].firstChild.nodeValue == 'file') { 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'; }

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-prune').style.display = 'none'; }

$(function {   if (mw.config.get('wgNamespaceNumber') == 6) {        $('#WikiaPageHeader').append(' ');        if ($('#ca-undelete').length) {            $('#WikiaPageHeader').append('Undelete | ');        }        $('#WikiaPageHeader').append('Log');        mw.util.addPortletLink('p-cactions', mw.util.wikiGetlink( 'Special:Log?page=' + mw.config.get('wgPageName')), 'Log');    } });