From 9cb281868f544957582b53e89da1b87783221c30 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Thu, 11 Jan 2018 11:55:17 +0100 Subject: [PATCH] Replace getElementById by shortcut for querySelector (requires IE8) --- adminer/create.inc.php | 2 +- adminer/database.inc.php | 2 +- adminer/include/adminer.inc.php | 4 ++-- adminer/include/functions.inc.php | 2 +- adminer/schema.inc.php | 2 +- adminer/scheme.inc.php | 2 +- adminer/static/editing.js | 18 +++++++++--------- adminer/static/functions.js | 26 +++++++++++++++++--------- adminer/trigger.inc.php | 2 +- adminer/user.inc.php | 2 +- editor/include/adminer.inc.php | 6 +++--- plugins/tables-filter.php | 8 ++++---- plugins/tinymce.php | 2 +- 13 files changed, 43 insertions(+), 35 deletions(-) diff --git a/adminer/create.inc.php b/adminer/create.inc.php index 19ae3f53..e57290dd 100644 --- a/adminer/create.inc.php +++ b/adminer/create.inc.php @@ -163,7 +163,7 @@ foreach ($engines as $engine) {

: " autocapitalize="off"> - + " . optionlist(array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . "" : ""); ?> "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?> diff --git a/adminer/database.inc.php b/adminer/database.inc.php index a0c06b4f..98349f91 100644 --- a/adminer/database.inc.php +++ b/adminer/database.inc.php @@ -66,7 +66,7 @@ echo ($_POST["add_x"] || strpos($name, "\n") 'mssql' => "ms187963.aspx", )) : ""); ?> - + " autocapitalize="off"> \n"; @@ -413,7 +413,7 @@ focus(document.getElementById('username')); json_row($key); } echo ";\n"; - echo "selectFieldChange(document.getElementById('form'));\n"; + echo "selectFieldChange(qs('#form'));\n"; echo "\n"; echo "\n"; } diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index da99c9cc..ad71a341 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -1383,7 +1383,7 @@ function edit_form($TABLE, $fields, $row, $update) { } } echo ($update ? "\n" - : ($_POST || !$fields ? "" : "\n") + : ($_POST || !$fields ? "" : "\n") ); if (isset($_GET["select"])) { hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"])); diff --git a/adminer/schema.inc.php b/adminer/schema.inc.php index 1bc7241a..dea8a5d0 100644 --- a/adminer/schema.inc.php +++ b/adminer/schema.inc.php @@ -51,7 +51,7 @@ foreach (table_status('', true) as $table => $table_status) {

+ ' + message + '
'; ajaxStatus.className = ajaxStatus.className.replace(/ hidden/g, ''); @@ -584,7 +592,7 @@ function ajaxForm(form, message, button) { return ajax(url, function (request) { setHtml('ajaxstatus', request.responseText); if (window.jush) { - jush.highlight_tag(document.getElementById('ajaxstatus').getElementsByTagName('code'), 0); + jush.highlight_tag(qs('#ajaxstatus').getElementsByTagName('code'), 0); } }, data, message); } @@ -678,7 +686,7 @@ function selectLoadMore(a, limit, loading) { return ajax(href, function (request) { var tbody = document.createElement('tbody'); tbody.innerHTML = request.responseText; - document.getElementById('table').appendChild(tbody); + qs('#table').appendChild(tbody); if (tbody.children.length < limit) { a.parentNode.removeChild(a); } else { diff --git a/adminer/trigger.inc.php b/adminer/trigger.inc.php index 4270770e..42afb976 100644 --- a/adminer/trigger.inc.php +++ b/adminer/trigger.inc.php @@ -40,7 +40,7 @@ page_header(($name != "" ? lang('Alter trigger') . ": " . h($name) : lang('Creat

: " maxlength="64" autocapitalize="off"> - +

diff --git a/adminer/user.inc.php b/adminer/user.inc.php index f45078ab..4d9afd9f 100644 --- a/adminer/user.inc.php +++ b/adminer/user.inc.php @@ -135,7 +135,7 @@ if ($_POST) { " autocapitalize="off"> " autocapitalize="off"> "> - + diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index ae405202..e0dd1383 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -59,7 +59,7 @@ class Adminer { \n"; @@ -399,7 +399,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 $field = idf_escape($_POST["email_field"]); $subject = $_POST["email_subject"]; $message = $_POST["email_message"]; - preg_match_all('~\\{\\$([a-z0-9_]+)\\}~i', "$subject.$message", $matches); // allows {$name} in subject or message + preg_match_all('~\\{\\$('#' + [a-z0-9_]+)\\}~i', "$subject.$message", $matches); // allows {$name} in subject or message $rows = get_rows("SELECT DISTINCT $field" . ($matches[1] ? ", " . implode(", ", array_map('idf_escape', array_unique($matches[1]))) : "") . " FROM " . table($_GET["select"]) . " WHERE $field IS NOT NULL AND $field != ''" . ($where ? " AND " . implode(" AND ", $where) : "") @@ -488,7 +488,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 return "$function()"; } $return = $value; - if (preg_match('~date|timestamp~', $field["type"]) && preg_match('(^' . str_replace('\\$1', '(?P\\d*)', preg_replace('~(\\\\\\$([2-6]))~', '(?P\\d{1,2})', preg_quote(lang('$1-$3-$5')))) . '(.*))', $value, $match)) { + if (preg_match('~date|timestamp~', $field["type"]) && preg_match('(^' . str_replace('\\$1', '(?P\\d*)', preg_replace('~(\\\\\\$('#' + [2-6]))~', '(?P\\d{1,2})', preg_quote(lang('$1-$3-$5')))) . '(.*))', $value, $match)) { $return = ($match["p1"] != "" ? $match["p1"] : ($match["p2"] != "" ? ($match["p2"] < 70 ? 20 : 19) . $match["p2"] : gmdate("Y"))) . "-$match[p3]$match[p4]-$match[p5]$match[p6]" . end($match); } $return = ($field["type"] == "bit" && preg_match('~^[0-9]+$~', $value) ? $return : q($return)); diff --git a/plugins/tables-filter.php b/plugins/tables-filter.php index 72297121..ef278f32 100644 --- a/plugins/tables-filter.php +++ b/plugins/tables-filter.php @@ -28,7 +28,7 @@ var tablesFilterTimeout = null; var tablesFilterValue = ''; function tablesFilter(){ - var value = document.getElementById('filter-field').value.toLowerCase(); + var value = qs('#filter-field').value.toLowerCase(); if (value == tablesFilterValue) { return; } @@ -40,7 +40,7 @@ function tablesFilter(){ if (sessionStorage) { sessionStorage.setItem('adminer_tables_filter', value); } - var tables = document.getElementById('tables').getElementsByTagName('li'); + var tables = qs('#tables').getElementsByTagName('li'); for (var i = 0; i < tables.length; i++) { var a = tables[i].getElementsByTagName('a')[1]; var text = tables[i].getAttribute('data-table-name'); @@ -60,10 +60,10 @@ function tablesFilterInput() { } if (sessionStorage){ - var db = document.getElementById('dbs').getElementsByTagName('select')[0]; + var db = qs('#dbs').getElementsByTagName('select')[0]; db = db.options[db.selectedIndex].text; if (db == sessionStorage.getItem('adminer_tables_filter_db') && sessionStorage.getItem('adminer_tables_filter')){ - document.getElementById('filter-field').value = sessionStorage.getItem('adminer_tables_filter'); + qs('#filter-field').value = sessionStorage.getItem('adminer_tables_filter'); tablesFilter(); } sessionStorage.setItem('adminer_tables_filter_db', db); diff --git a/plugins/tinymce.php b/plugins/tinymce.php index 8e47516a..1bd52c7a 100644 --- a/plugins/tinymce.php +++ b/plugins/tinymce.php @@ -71,7 +71,7 @@ tinyMCE.init({ return "" . h($value) . "