User:IAMAHIPO ocolor/rcnst.js

window.onload = function { 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; loglist = []; 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; logname = items[j].getElementsByTagName("a")[0].innerHTML; if (logname != "diff" && logname != "hist" && loglist.indexOf(logname) == -1) loglist.push(logname); }   }    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; }   for (i in loglist) { if (!include && (temp.indexOf(loglist[i]) != -1)) RCNSTList[loglist[i]] = false; else if (include && (temp.indexOf(loglist[i])) == -1) RCNSTList[loglist[i]] = false; }   s = RCNSTbeforecheckboxes; for (i in nslist) { if (RCNSTList[i] == false) insert = ''; else insert = 'checked="checked"'; s += RCNSTbeforecheckbox + '' + nslist[i] + ' ' + RCNSTaftercheckbox; }   for (i in loglist) { if (RCNSTList[loglist[i]] == false) insert = ''; else insert = 'checked="checked"'; s += RCNSTbeforecheckbox + '' + loglist[i] + ' ' + 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; }   for (i in loglist) { if (document.getElementsByName("RCNSTl" + i)[0].checked) RCNSTList[loglist[i]] = true; else RCNSTList[loglist[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")[0]; if (page.innerHTML == "diff" || page.innerHTML == "hist") { page = page.href; page = page.substring(page.indexOf("?title=") + 7); page = page.substring(0, page.indexOf("&curid=")); page = page.substring(0, page.indexOf(":")).replace("_", " "); page = nslist.indexOf(page); if (page == -1) page = 0; } else page = page.innerHTML; if (RCNSTList[page]) { 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"; }   } }