]> git.joonet.de Git - adminer.git/commitdiff
Simplify storing executed SQL queries to bookmarks
authorJakub Vrana <jakub@vrana.cz>
Mon, 1 Oct 2018 15:08:58 +0000 (17:08 +0200)
committerJakub Vrana <jakub@vrana.cz>
Mon, 1 Oct 2018 15:08:58 +0000 (17:08 +0200)
adminer/sql.inc.php
adminer/static/editing.js
adminer/static/functions.js
changes.txt

index 5f632f820db49f4a352a8e20f0bdd50110179efd..c1549a3f25657ce83407646ac0e9ac31b0a9b2cf 100644 (file)
@@ -219,7 +219,7 @@ if (!isset($_GET["import"])) {
        }
        echo "<p>";
        textarea("query", $q, 20);
-       echo ($_POST ? "" : script("qs('textarea').focus();"));
+       echo script(($_POST ? "" : "qs('textarea').focus();\n") . "qs('#form').onsubmit = partial(sqlSubmit, qs('#form'), '" . remove_from_uri("sql|limit|error_stops|only_errors") . "');");
        echo "<p>$execute\n";
        echo lang('Limit rows') . ": <input type='number' name='limit' class='size' value='" . h($_POST ? $_POST["limit"] : $_GET["limit"]) . "'>\n";
        
index 25d8c49ee8098144a9581e535d89431dfff5b93a..8ef5a93d59044847ce26f1a87bf1f19589049fb0 100644 (file)
@@ -595,6 +595,23 @@ function indexesAddColumn(prefix) {
 
 
 
+/** Updates the form action
+* @param HTMLFormElement
+* @param string
+*/
+function sqlSubmit(form, root) {
+       if (encodeURIComponent(form['query'].value).length < 2e3) {
+               form.action = root
+                       + '&sql=' + encodeURIComponent(form['query'].value)
+                       + (form['limit'].value ? '&limit=' + +form['limit'].value : '')
+                       + (form['error_stops'].checked ? '&error_stops=1' : '')
+                       + (form['only_errors'].checked ? '&only_errors=1' : '')
+               ;
+       }
+}
+
+
+
 /** Handle changing trigger time or event
 * @param RegExp
 * @param string
index c34b1cf934945175c2d680a3a45087989a8b6361..084fb1bd25d4d478b5788b6ad07350a8ef3a68a2 100644 (file)
@@ -491,6 +491,9 @@ function bodyKeydown(event, button) {
                if (button) {
                        target.form[button].click();
                } else {
+                       if (target.form.onsubmit) {
+                               target.form.onsubmit();
+                       }
                        target.form.submit();
                }
                target.focus();
index d19c85f9628e2b3c19d5283a4e68b683c6c1d605..859063bb6e0473d83ee8a2ab61b2a6cf3c2087db 100644 (file)
@@ -1,4 +1,5 @@
 Adminer 4.7.0-dev:
+Simplify storing executed SQL queries to bookmarks
 Warn when using password with leading or trailing spaces
 Fix inline editing of empty cells (regression from 4.6.3)
 Allow adding more than two indexes and forign key columns at a time (regression from 4.4.0)