From 6d7e4ed82d4c66b8bfc047f43a18a45174b96462 Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Sun, 6 Apr 2003 19:14:36 +0000 Subject: [PATCH] Patch #705899 from Alexis Soulard --- ChangeLog | 3 +++ libraries/functions.js | 42 +++++++++++++++++++++++++++++++++- tbl_query_box.php3 | 52 ++++++++++++++++++++++-------------------- 3 files changed, 71 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 236295c32..6d569a0e6 100755 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ $Id$ $Source$ 2003-04-06 Garvin Hicking + * tbl_query_box.php, libraries/functions.js: Patch #705899 included. + Now multiple fields can be inserted at cursor position (Mozilla/IE) + in the sql query textarea. Thanks to Alexis Soulard (alexis_soulard) * header.inc.php3, footer.inc.php3, libraries/common.lib.php3, libraries/relation.lib.php3: RFE #715914: Sort query history by (autoincrement) key instead of timevalue. Only save queries in diff --git a/libraries/functions.js b/libraries/functions.js index 9e6816245..4fac37f47 100644 --- a/libraries/functions.js +++ b/libraries/functions.js @@ -636,9 +636,49 @@ function onKeyDownArrowsHandler(e) { e.returnValue = false; } +/** + * Inserts multiple fields. + * + */ +function insertValueQuery() { + var myQuery = document.sqlform.sql_query; + var myListBox = document.sqlform.dummy; + + if(myListBox.options.length > 0) { + var chaineAj = ""; + var NbSelect = 0; + for(var i=0; i 1) + chaineAj += ", "; + chaineAj += myListBox.options[i].value; + } + } + + //IE support + if (document.selection) { + myQuery.focus(); + sel = document.selection.createRange(); + sel.text = chaineAj; + document.sqlform.insert.focus(); + } + //MOZILLA/NETSCAPE support + else if (document.sqlform.sql_query.selectionStart || document.sqlform.sql_query.selectionStart == "0") { + var startPos = document.sqlform.sql_query.selectionStart; + var endPos = document.sqlform.sql_query.selectionEnd; + var chaineSql = document.sqlform.sql_query.value; + + myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length); + } else { + myQuery.value += chaineAj; + } + } +} + /** * listbox redirection */ function goToUrl(selObj, goToLocation){ - eval("document.location.href = '" + goToLocation + "pos=" + selObj.options[selObj.selectedIndex].value + "'"); + eval("document.location.href = '" + goToLocation + "pos=" + selObj.options[selObj.selectedIndex].value + "'"); } diff --git a/tbl_query_box.php3 b/tbl_query_box.php3 index cd62a440f..d22bc372f 100755 --- a/tbl_query_box.php3 +++ b/tbl_query_box.php3 @@ -86,35 +86,38 @@ if ($cfg['QueryFrame'] && (!$cfg['QueryFrameJS'] || ($cfg['QueryFrameJS'] && !$d - -
  • - - - 0) { ?> -    : - - - -
    -
    -
    + + + + + 0) { ?> + + + +
    + ' : ' ') . PMA_showMySQLDocu('Reference', 'SELECT'); ?> +
    + +
    ' : '') . $strFields; ?>:
    +

    + +
     
    @@ -245,7 +248,6 @@ if (!isset($is_inside_querywindow) || if (!isset($is_inside_querywindow) || (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' || $querydisplay_tab == 'sql' || $querydisplay_tab == 'full' || ($querydisplay_tab == 'history' && $bookmark_go)))) { ?> -