diff --git a/adminer/static/functions.js b/adminer/static/functions.js index fd62cd03..8dbf4c18 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -106,10 +106,11 @@ function tableClick(event) { var click = (!window.getSelection || getSelection().isCollapsed); var el = event.target || event.srcElement; while (!/^tr$/i.test(el.tagName)) { - if (/^table$/i.test(el.tagName)) { - return; - } - if (/^(a|input|textarea)$/i.test(el.tagName)) { + if (/^(table|a|input|textarea)$/i.test(el.tagName)) { + if (el.type != 'checkbox') { + return; + } + checkboxClick(event, el); click = false; } el = el.parentNode; @@ -122,6 +123,39 @@ function tableClick(event) { trCheck(el); } +var lastChecked; + +/** Shift-click on checkbox for multiple selection. + * @param MouseEvent + * @param HTMLInputElement + */ +function checkboxClick(event, el) { + if (!el.name) { + return; + } + if (event.shiftKey && (!lastChecked || lastChecked.name == el.name)) { + var checked = (lastChecked ? lastChecked.checked : true); + var inputs = el.parentNode.parentNode.parentNode.getElementsByTagName('input'); + var checking = !lastChecked; + for (var i=0; i < inputs.length; i++) { + var input = inputs[i]; + if (input.name === el.name) { + if (checking) { + input.checked = checked; + trCheck(input); + } + if (input === el || input === lastChecked) { + if (checking) { + break; + } + checking = true; + } + } + } + } + lastChecked = el; +} + /** Set HTML code of an element * @param string * @param string undefined to set parentNode to   diff --git a/changes.txt b/changes.txt index 90b21d71..14e14b78 100644 --- a/changes.txt +++ b/changes.txt @@ -1,7 +1,8 @@ Adminer 3.4.0-dev: -Print current time next to executed SQL queries Highlight code in SQL command by CodeMirror Link to descending order +Shift+click on checkbox to select consecutive rows +Print current time next to executed SQL queries Warn about selecting data without index Allow specifying database in login form Link to original table in EXPLAIN of SELECT * FROM table t