]> git.joonet.de Git - adminer.git/commitdiff
Avoid qsl in a loop
authorJakub Vrana <jakub@vrana.cz>
Wed, 7 Feb 2018 17:28:26 +0000 (18:28 +0100)
committerJakub Vrana <jakub@vrana.cz>
Wed, 7 Feb 2018 17:55:16 +0000 (18:55 +0100)
Table with 500 rows rendered in 1.5 instead of 5.5 seconds.

adminer/select.inc.php
adminer/static/functions.js
changes.txt

index f165d1a24e3cdf922edfef629373342e8f8a63bc..4fdf439f4fe9114dd5e92dc135e7eb95f701211e 100644 (file)
@@ -440,8 +440,10 @@ if (!$columns && support("table")) {
                                                        echo "<td>" . ($text ? "<textarea name='$id' cols='30' rows='" . (substr_count($row[$key], "\n") + 1) . "'>$h_value</textarea>" : "<input name='$id' value='$h_value' size='$lengths[$key]'>");
                                                } else {
                                                        $long = strpos($val, "<i>...</i>");
-                                                       echo "<td id='$id'>$val</td>";
-                                                       echo script("qsl('td').onclick = partialArg(selectClick, " . ($long ? 2 : ($text ? 1 : 0)) . ($editable ? "" : ", '" . h(lang('Use edit link to modify this value.')) . "'") . ");", "");
+                                                       echo "<td id='$id' data-text='" . ($long ? 2 : ($text ? 1 : 0)) . "'"
+                                                               . ($editable ? "" : " data-warning='" . h(lang('Use edit link to modify this value.')) . "'")
+                                                               . ">$val</td>"
+                                                       ;
                                                }
                                        }
                                }
index effb3aa78617fd5e045ff3318b1875c6ab158d6b..7bdd88013a0c8de6b0c37b3f4c15b2c87aeb7b62 100644 (file)
@@ -246,6 +246,13 @@ function formChecked(el, name) {
 * @param [boolean] force click
 */
 function tableClick(event, click) {
+       var td = parentTag(getTarget(event), 'td');
+       var text;
+       if (td && (text = td.getAttribute('data-text'))) {
+               if (selectClick.call(td, event, +text, td.getAttribute('data-warning'))) {
+                       return;
+               }
+       }
        click = (click || !window.getSelection || getSelection().isCollapsed);
        var el = getTarget(event);
        while (!isTag(el, 'tr')) {
@@ -667,6 +674,7 @@ function ajaxForm(form, message, button) {
 * @param MouseEvent
 * @param number display textarea instead of input, 2 - load long text
 * @param [string] warning to display
+* @return boolean
 * @this HTMLElement
 */
 function selectClick(event, text, warning) {
@@ -676,7 +684,8 @@ function selectClick(event, text, warning) {
                return;
        }
        if (warning) {
-               return alert(warning);
+               alert(warning);
+               return true;
        }
        var original = td.innerHTML;
        text = text || /\n/.test(original);
@@ -732,6 +741,7 @@ function selectClick(event, text, warning) {
                range.moveEnd('character', -input.value.length + pos);
                range.select();
        }
+       return true;
 }
 
 
index fe6e1352d60a7e1eff085f729aaead8a32822cea..eb5d5cb378b36d6c91db83b954e1d1983a822de8 100644 (file)
@@ -1,4 +1,5 @@
 Adminer 4.6.1-dev:
+Speed up rendering of long tables
 MySQL: Support non-utf8 charset in search in column
 MySQL: Support geometry in MySQL 8 (bug #574)
 SQLite: Allow deleting PRIMARY KEY from tables with auto increment