User:Greenpickle/rcnst.js: Difference between revisions
Jump to navigation
Jump to search
Greenpickle (talk | contribs) (Created page with '/* MediaWiki recent changes namespace toggler version 0.5 by Greenpickle. Put the code on any script page you want, such as User:Name/monobook.js, Mediawiki:Common.js, etc.. T…') |
Greenpickle (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
window.onload = function () { | window.onload = function () { | ||
if () include | |||
if (document.body.className.indexOf("page-Special_RecentChanges") == -1) return; | if (document.body.className.indexOf("page-Special_RecentChanges") == -1) return; | ||
choice = document.getElementById("namespace").childNodes; | choice = document.getElementById("namespace").childNodes; |
Revision as of 12:10, October 11, 2009
window.onload = function () {
if () include
if (document.body.className.indexOf("page-Special_RecentChanges") == -1) return;
choice = document.getElementById("namespace").childNodes;
nslist = [];
for (i in choice) if (choice[i].tagName == "OPTION" && choice[i].value != "") nslist[choice[i].value] = choice[i].innerHTML;
temp = RCNSTList;
RCNSTList = [];
for (i in nslist) {
if (!include && (temp.indexOf(nslist[i]) != -1)) RCNSTList[i] = false;
else if (include && (temp.indexOf(nslist[i])) == -1) RCNSTList[i] = false;
}
s = RCNSTbeforecheckboxes;
for (i in nslist) {
if (RCNSTList[i] == false) insert = '';
else insert = 'checked="checked"';
s += RCNSTbeforecheckbox + '<input type="checkbox" ' + insert + 'name="RCNST' + i + '" onclick="RCNST()" /><label for="RCNST' + i + '">' + nslist[i] + '</label>' + RCNSTaftercheckbox;
}
s += RCNSTaftercheckboxes;
document.getElementsByClassName("rcoptions")[0].innerHTML += s;
RCNST();
}
function RCNST () {
for (i in nslist) {
if (document.getElementsByName("RCNST" + i)[0].checked) RCNSTList[i] = true;
else RCNSTList[i] = false;
}
days = document.getElementsByClassName("special");
for (i in days) {
if (days[i].tagName != "UL") continue;
items = days[i].childNodes;
for (j = 0; j < items.length; j++) {
if (items[j].tagName != "LI") continue;
page = items[j].getElementsByTagName("a");
for (k in page) if (page[k].innerHTML == "hist") {
page = page[k];
break;
}
page = page.href;
page = page.substring(page.indexOf("?title=") + 7);
page = page.substring(0, page.indexOf("&curid="));
page = page.substring(0, page.indexOf(":")).replace("_", " ");
ns = nslist.indexOf(page);
if (ns == -1) ns = 0;
if (RCNSTList[ns]) {
if (items[j].className.indexOf(" rcnsthidden") != -1) items[j].className = items[j].className.substring(0, items[j].className.indexOf(" rcnsthidden"));
} else if (items[j].className.indexOf(" rcnsthidden") == -1) items[j].className += " rcnsthidden";
}
}
}