diff --git a/lib/javascript-static.js b/lib/javascript-static.js index 808165303d8..579b640d287 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -69,3 +69,30 @@ function submitFormById(id) { return theform.submit(); } } + +function select_all_in(elTagName, elId, elClass) { + var inputs = document.getElementsByTagName('INPUT'); + inputs = filterByParent(inputs, function(el) {return findParentNode(el, elTagName, elId, elClass);}); + for(var i = 0; i < inputs.length; ++i) { + if(inputs[i].type == 'checkbox') { + inputs[i].checked = 'checked'; + } + } +} + +function deselect_all_in(elTagName, elId, elClass) { + var inputs = document.getElementsByTagName('INPUT'); + inputs = filterByParent(inputs, function(el) {return findParentNode(el, elTagName, elId, elClass);}); + for(var i = 0; i < inputs.length; ++i) { + if(inputs[i].type == 'checkbox') { + inputs[i].checked = ''; + } + } +} + +function confirm_if(expr, message) { + if(!expr) { + return true; + } + return confirm(message); +}