Added a clipboard icon next to SQL command to expand and copy to clipboard

This commit is contained in:
Lionel Laffineur 2023-09-21 20:57:52 +02:00 committed by Gerry Demaret
parent ecbbe8de33
commit c21d644947
2 changed files with 5 additions and 1 deletions

View file

@ -649,7 +649,7 @@ class Adminer {
}
$history[$_GET["db"]][] = array($query, time(), $time); // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
$sql_id = "sql-" . count($history[$_GET["db"]]);
$return = "<a href='#$sql_id' class='toggle'>" . lang('SQL command') . "</a>\n";
$return = "<a href='#$sql_id' class='toggle'>" . lang('SQL command') . "</a> <a href='#' class='copy-to-clipboard icon expand' data-expand-id='$sql_id'></a>\n";
if (!$failed && ($warnings = $driver->warnings())) {
$id = "warnings-" . count($history[$_GET["db"]]);
$return = "<a href='#$id' class='toggle'>" . lang('Warnings') . "</a>, $return<div id='$id' class='hidden'>\n$warnings</div>\n";

View file

@ -873,6 +873,9 @@ function setupCopyToClipboard(document) {
nodeSql = document.querySelector("textarea.sqlarea");
}
if (nodeSql != null && nodeSql != undefined) {
if (node.classList.contains('expand')) {
document.getElementById(node.getAttribute('data-expand-id')).classList.remove("hidden");
}
copyToClipboard(nodeSql);
}
});
@ -883,6 +886,7 @@ function setupCopyToClipboard(document) {
* @param HTMLElement
*/
function copyToClipboard(el) {
var nodeName = el.nodeName.toLowerCase();
if (nodeName == 'code') {
var range = document.createRange();