User:Mudd1/common.js

//Contribution list items var lilist = document.getElementById("bodyContent"); var lilistitems = lilist.getElementsByTagName("li");

//Toggle link text var commonText1 = " | Show "; var commonText3 = " contributions"; var filterLCtext = commonText1 + "filterLatestContrib;" + commonText2 + "latest" + commonText3; var showAllText = commonText1 + "showAllContrib;" + commonText2 + "all" + commonText3;

if (wgCanonicalSpecialPageName == "Contributions") { //Show the toggle link document.getElementById("coordinates").innerHTML += "" + filterLCtext + " ";

//Get the target user name var targetUserName = document.getElementsByName("target")[0].value;

//Compare target user name with logged in user name var toggleLinkText = ""; if (targetUserName == wgUserName) { filterLatestContrib; } }

function filterLatestContrib { var pagesAlreadySeen = new Array;

//Look for and hide older contributions for (var i = 0; i < lilistitems.length; i++) { var alist = lilistitems[i].getElementsByTagName("a");

if (alist.length >= 1) { if (pagesAlreadySeen.indexOf(alist[0].title) == -1) { pagesAlreadySeen.push(alist[0].title); } else { lilistitems[i].style.display = "none"; }   }  }

//Change toggle link text document.getElementById("filterLatestContribLink").innerHTML = showAllText; }

function showAllContrib { //Look for and show hidden contributions for (var i = 0; i < lilistitems.length; i++) { if (lilistitems[i].style.display == "none") { lilistitems[i].style.display = ""; } }

//Change toggle link text document.getElementById("filterLatestContribLink").innerHTML = filterLCtext; }