-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathtables-filter.php
More file actions
96 lines (90 loc) · 2.89 KB
/
Copy pathtables-filter.php
File metadata and controls
96 lines (90 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/** Filter names in the table list
* @link https://www.adminer.org/plugins/#use
* @author Jakub Vrana, https://www.vrana.cz/
* @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)
*/
class AdminerTablesFilter extends Adminer\Plugin {
function tablesPrint($tables) {
if (Adminer\support("single_table")) {
return; // there is nothing to filter
}
?>
<script<?php echo Adminer\nonce(); ?>>
let tablesFilterTimeout = null;
let tablesFilterValue = '';
function tablesFilter() {
const value = qs('#filter-field').value.toLowerCase();
if (value == tablesFilterValue) {
return;
}
tablesFilterValue = value;
let reg;
if (value != '') {
reg = (value + '').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, '\\$1');
reg = new RegExp('('+ reg + ')', 'gi');
}
if (sessionStorage) {
sessionStorage.setItem('adminer_tables_filter', value);
}
for (const table of qsa('li', qs('#tables'))) {
let a = null;
let text = table.getAttribute('data-table-name');
if (text == null) {
a = qsa('a', table)[1];
text = a.innerHTML.trim();
table.setAttribute('data-table-name', text);
a.setAttribute('data-link', 'main');
} else {
a = qs('a[data-link="main"]', table);
}
if (value == '') {
table.className = '';
a.innerHTML = text;
} else {
table.className = (text.toLowerCase().indexOf(value) == -1 ? 'hidden' : '');
a.innerHTML = text.replace(reg, '<strong>$1</strong>');
}
}
}
function tablesFilterInput() {
window.clearTimeout(tablesFilterTimeout);
tablesFilterTimeout = window.setTimeout(tablesFilter, 200);
}
sessionStorage && document.addEventListener('DOMContentLoaded', () => {
let select = qs('#dbs') && qs('#dbs').querySelector('select'); // there is no select in drivers with a single database
let db = (select ? select.options[select.selectedIndex].text : '');
if (db == sessionStorage.getItem('adminer_tables_filter_db') && sessionStorage.getItem('adminer_tables_filter')){
qs('#filter-field').value = sessionStorage.getItem('adminer_tables_filter');
tablesFilter();
}
sessionStorage.setItem('adminer_tables_filter_db', db);
});
</script>
<p class="jsonly"><?php echo $this->lang('Filter'); ?>: <input id="filter-field" autocomplete="off" type="search"<?php echo Adminer\on('input', 'tablesFilterInput'); ?>>
<?php
}
protected $translations = array(
'cs' => array(
'' => 'Filtruje názvy v seznamu tabulek',
'Filter' => 'Filtr',
),
'de' => array(
'' => 'Filtern Sie Namen in der Tabellenliste',
),
'pl' => array(
'' => 'Filtruj nazwy na liście tabel',
),
'ro' => array(
'' => 'Nume de filtre în lista de tabele',
),
'ja' => array(
'' => 'テーブル一覧をテーブル名でフィルタリング',
),
'hr' => array(
'' => 'Filtriranje tablice prema imenu',
'Filter' => 'Filtar',
),
);
}