]> git.joonet.de Git - adminer.git/commitdiff
Simplify copying of redirected links
authorJakub Vrana <jakub@vrana.cz>
Thu, 20 Mar 2014 17:04:48 +0000 (10:04 -0700)
committerJakub Vrana <jakub@vrana.cz>
Thu, 20 Mar 2014 17:04:48 +0000 (10:04 -0700)
adminer/select.inc.php
adminer/static/functions.js
changes.txt

index 3e70feb651aad2bb75214de3110680f920c1104c..b7ce53f647cc22da38273f542c70717881ebf688 100644 (file)
@@ -515,7 +515,7 @@ if (!$columns && support("table")) {
                                echo "</div></fieldset>\n";
                        }
 
-                       echo (!$group && $select ? "" : "<script type='text/javascript'>tableCheck();</script>\n");
+                       echo "<script type='text/javascript'>selectLinks(document.getElementById('table'));" . (!$group && $select ? "" : " tableCheck();") . "</script>\n";
                }
 
                if ($adminer->selectImportPrint()) {
index c18fe9bc4c2194bd7e5ca1e75c5a54f67198ba27..27836512eca8ab2e2f664f718400ec392fb8d90b 100644 (file)
@@ -179,6 +179,14 @@ function tableClick(event, click) {
        var el = getTarget(event);
        while (!isTag(el, 'tr')) {
                if (isTag(el, 'table|a|input|textarea')) {
+                       if (el.origHref) {
+                               // open('about:blank').document.write('<meta http-equiv="Refresh">') still passes the referer in Chrome
+                               var href = el.href;
+                               el.href = el.origHref;
+                               setTimeout(function () {
+                                       el.href = href;
+                               }, 0);
+                       }
                        if (el.type != 'checkbox') {
                                return;
                        }
@@ -195,6 +203,21 @@ function tableClick(event, click) {
        trCheck(el);
 }
 
+/** Clean redirect links to simplify their copying
+* @param HTMLElement
+*/
+function selectLinks(table) {
+       var as = table.getElementsByTagName('a');
+       for (var i = 0; i < as.length; i++) {
+               var a = as[i];
+               var match = /^https?:\/\/www\.adminer\.org\/redirect\/\?url=(.+)/.exec(a.href); //! rewrites also links intentionally stored with http://www.adminer.org/redirect/?url=
+               if (match) {
+                       a.origHref = a.href;
+                       a.href = decodeURIComponent(match[1]);
+               }
+       }
+}
+
 var lastChecked;
 
 /** Shift-click on checkbox for multiple selection.
@@ -661,6 +684,7 @@ function selectLoadMore(a, limit, loading) {
                        var tbody = document.createElement('tbody');
                        tbody.innerHTML = request.responseText;
                        document.getElementById('table').appendChild(tbody);
+                       selectLinks(tbody);
                        if (tbody.children.length < limit) {
                                a.parentNode.removeChild(a);
                        } else {
index 630586ada12174718f9eb351a774fdaaabb73d63..a15be7539b863df99d6bfdf48f55a6d7e7d46e6d 100644 (file)
@@ -4,6 +4,7 @@ Compute number of tables in the overview explicitly
 Display edit form after error in clone or multi-edit
 Display time of the select command
 Print elapsed time in HTML instead of SQL command comment
+Simplify copying of redirected links
 Improve gzip export ratio (bug #387)
 Fix enum types in routines (bug #391)
 MySQL: Fix editing rows by binary values, bug since Adminer 3.7.1