User:Mike Dillon/Scripts/cleanup.js

// Requires User:Mike Dillon/Scripts/navbox.js

//

// Create the cleanup box $(function { addNavbox('u-cleanup', 'Cleanup') });

// Add a new list item to the "cleanup" div function addCleanupBoxLink(url, name, id, title, key){ var tb = document.getElementById('u-cleanup').getElementsByTagName('ul')[0]; return addlilink(tb, url, name, id, title, key); }

function addCleanupBoxText(text){ return addCleanupBoxLink(null, text); }

// Testing function getFileLinks { var elem = document.getElementById("filelinks"); if (!elem) return null;

var list = null; while (elem.nextSibling) { elem = elem.nextSibling;

if (elem.nodeName == 'UL') { list = elem; break; }   }

if (!list) return null;

var listitems = list.getElementsByTagName('li');

var fileLinks = new Array; for (i = 0; i < listitems.length; i++) { var item = listitems[i]; var itemLink = item.getElementsByTagName('a')[0]; if (itemLink) fileLinks.push(itemLink); }

return fileLinks; }

function countFileLinks { var fileLinks = getFileLinks; return fileLinks == null ? null : fileLinks.length; }

function touchFileLinks { var fileLinks = getFileLinks;

var multi = new MultiEditor(fileLinks);

multi.processPages; }

$(function {    var fileLinks = countFileLinks;    if (fileLinks != null) {        var li = addCleanupBoxLink("javascript:touchFileLinks", "(touch)", "", "Touch file links");        li.insertBefore(document.createTextNode("File links: " + fileLinks + " "), li.childNodes[0]);   } });

//