diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 401e4f27..92c4c88a 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -238,8 +238,9 @@ class Adminer { . "$return\n" ; } - return "

" . h(str_replace("\n", " ", $query)) . " (" . format_time($start) . ")" + return "

\n"; } return " " . @date("H:i:s") . "" // @ - time zone may be not set - . " $return \n"; } diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index 5c263388..3685b320 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -97,7 +97,8 @@ if (!$error && $_POST) { $empty = false; $q = substr($query, 0, $pos); $commands++; - $print = "
" . $adminer->sqlCommandQuery($q) . "
\n"; + $print = "
" . $adminer->sqlCommandQuery($q) . "
\n"; + $print .= "" . lang('Copy to clipboard') . ""; if ($jush == "sqlite" && preg_match("~^$space*+ATTACH\\b~i", $q, $match)) { // PHP doesn't support setting SQLITE_LIMIT_ATTACHED echo $print; diff --git a/adminer/static/functions.js b/adminer/static/functions.js index 9242db32..087e2510 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -662,7 +662,7 @@ function ajaxForm(form, message, button) { } } data = data.join('&'); - + var url = form.action; if (!/post/i.test(form.method)) { url = url.replace(/\?.*/, '') + '?' + data; @@ -861,7 +861,29 @@ function findDefaultSubmit(el) { } } +/** Initialize the copy to clipboard feature + * @param HTMLElement + */ +function setupCopyToClipboard(document) { + var node = document.querySelector("a.copy-to-clipboard"); + if (node) { + node.addEventListener("click", function() { + copyToClipboard(document.querySelector("code.copy-to-clipboard")); + }); + } +} +/** Copy element's content in clipboard + * @param HTMLElement + */ +function copyToClipboard(el) { + var range = document.createRange(); + range.selectNode(el); + window.getSelection().removeAllRanges(); + window.getSelection().addRange(range); + document.execCommand("copy"); + window.getSelection().removeAllRanges(); +} /** Add event listener * @param HTMLElement