From: Brion Vibber Date: Thu, 16 Mar 2006 01:34:07 +0000 (+0000) Subject: Clean up the history radio button handler a little bit in case someone does X-Git-Tag: 1.6.0~207 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=e07ea3eb41cfa3fb14512bd31168b270acb7ec13;p=lhc%2Fweb%2Fwiklou.git Clean up the history radio button handler a little bit in case someone does something silly like trying to put other buttons or check boxes in there. It'll now only operate on the oldid and diff bits; also it uses local variables instead of globals (yecch). --- diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 93b18387a0..63ea593535 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -84,12 +84,12 @@ function toggleVisibility(_levelId, _otherId, _linkId) { // 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; @@ -98,16 +98,26 @@ function histrowinit() { 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