2011-05-24 15:35:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/** Use filter in tables list
|
2015-09-08 16:23:25 +00:00
|
|
|
* @link https://www.adminer.org/plugins/#use
|
2017-02-27 12:43:33 +00:00
|
|
|
* @author Jakub Vrana, https://www.vrana.cz/
|
2018-01-14 10:03:54 +00:00
|
|
|
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
|
|
|
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
|
2011-05-24 15:35:57 +00:00
|
|
|
*/
|
|
|
|
class AdminerTablesFilter {
|
2016-05-31 19:02:16 +00:00
|
|
|
function tablesPrint($tables) { ?>
|
2018-01-13 21:17:00 +00:00
|
|
|
<script<?php echo nonce(); ?>>
|
2016-05-31 19:02:16 +00:00
|
|
|
var tablesFilterTimeout = null;
|
|
|
|
var tablesFilterValue = '';
|
|
|
|
|
|
|
|
function tablesFilter(){
|
2018-01-11 10:55:17 +00:00
|
|
|
var value = qs('#filter-field').value.toLowerCase();
|
2016-05-31 19:02:16 +00:00
|
|
|
if (value == tablesFilterValue) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tablesFilterValue = value;
|
|
|
|
if (value != '') {
|
|
|
|
var reg = (value + '').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, '\\$1');
|
|
|
|
reg = new RegExp('('+ reg + ')', 'gi');
|
|
|
|
}
|
2016-05-31 22:18:25 +00:00
|
|
|
if (sessionStorage) {
|
|
|
|
sessionStorage.setItem('adminer_tables_filter', value);
|
|
|
|
}
|
2018-01-11 12:42:45 +00:00
|
|
|
var tables = qsa('li', qs('#tables'));
|
2016-05-31 19:02:16 +00:00
|
|
|
for (var i = 0; i < tables.length; i++) {
|
2018-05-13 07:49:09 +00:00
|
|
|
var a = null;
|
2016-05-31 19:02:16 +00:00
|
|
|
var text = tables[i].getAttribute('data-table-name');
|
2018-05-13 07:49:09 +00:00
|
|
|
if (text == null) {
|
|
|
|
a = qsa('a', tables[i])[1];
|
|
|
|
text = a.innerHTML.trim();
|
|
|
|
|
|
|
|
tables[i].setAttribute('data-table-name', text);
|
|
|
|
a.setAttribute('data-link', 'main');
|
|
|
|
} else {
|
|
|
|
a = qs('a[data-link="main"]', tables[i]);
|
|
|
|
}
|
2016-05-31 19:02:16 +00:00
|
|
|
if (value == '') {
|
|
|
|
tables[i].className = '';
|
|
|
|
a.innerHTML = text;
|
|
|
|
} else {
|
|
|
|
tables[i].className = (text.toLowerCase().indexOf(value) == -1 ? 'hidden' : '');
|
|
|
|
a.innerHTML = text.replace(reg, '<strong>$1</strong>');
|
|
|
|
}
|
2011-05-24 15:35:57 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-31 19:02:16 +00:00
|
|
|
|
|
|
|
function tablesFilterInput() {
|
|
|
|
window.clearTimeout(tablesFilterTimeout);
|
|
|
|
tablesFilterTimeout = window.setTimeout(tablesFilter, 200);
|
|
|
|
}
|
|
|
|
|
2018-09-18 13:38:13 +00:00
|
|
|
sessionStorage && document.addEventListener('DOMContentLoaded', function () {
|
2018-01-11 11:07:33 +00:00
|
|
|
var db = qs('#dbs').querySelector('select');
|
2016-05-31 22:18:25 +00:00
|
|
|
db = db.options[db.selectedIndex].text;
|
|
|
|
if (db == sessionStorage.getItem('adminer_tables_filter_db') && sessionStorage.getItem('adminer_tables_filter')){
|
2018-01-11 10:55:17 +00:00
|
|
|
qs('#filter-field').value = sessionStorage.getItem('adminer_tables_filter');
|
2016-05-31 22:18:25 +00:00
|
|
|
tablesFilter();
|
|
|
|
}
|
|
|
|
sessionStorage.setItem('adminer_tables_filter_db', db);
|
2018-09-18 13:38:13 +00:00
|
|
|
});
|
2011-05-24 15:35:57 +00:00
|
|
|
</script>
|
2018-01-19 09:55:51 +00:00
|
|
|
<p class="jsonly"><input id="filter-field" autocomplete="off"><?php echo script("qs('#filter-field').oninput = tablesFilterInput;"); ?>
|
2011-05-24 15:35:57 +00:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
}
|