// page history stuff
// attach event handlers to the input elements on history page
function histrowinit() {
- hf = document.getElementById('pagehistory');
+ var hf = document.getElementById('pagehistory');
if (!hf)
return;
- lis = hf.getElementsByTagName('li');
+ var lis = hf.getElementsByTagName('li');
for (i = 0; i < lis.length; i++) {
- inputs = lis[i].getElementsByTagName('input');
+ var inputs = historyRadios(lis[i]);
if (inputs[0] && inputs[1]) {
inputs[0].onclick = diffcheck;
inputs[1].onclick = diffcheck;
diffcheck();
}
+function historyRadios(parent) {
+ var inputs = parent.getElementsByTagName('input');
+ var radios = [];
+ for (var i = 0; i < inputs.length; i++) {
+ if (inputs[i].name == "diff" || inputs[i].name == "oldid")
+ radios[radios.length] = inputs[i];
+ }
+ return radios;
+}
+
// check selection and tweak visibility/class onclick
function diffcheck() {
var dli = false; // the li where the diff radio is checked
var oli = false; // the li where the oldid radio is checked
- hf = document.getElementById('pagehistory');
+ var hf = document.getElementById('pagehistory');
if (!hf)
return;
- lis = hf.getElementsByTagName('li');
+ var lis = hf.getElementsByTagName('li');
for (i=0;i<lis.length;i++) {
- inputs = lis[i].getElementsByTagName('input');
+ var inputs = historyRadios(lis[i]);
if (inputs[1] && inputs[0]) {
if (inputs[1].checked || inputs[0].checked) { // this row has a checked radio button
if (inputs[1].checked && inputs[0].checked && inputs[0].value == inputs[1].value)