summaryrefslogtreecommitdiffstats
path: root/web/template
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2019-12-11 20:38:27 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2019-12-11 21:40:59 +0100
commit58aa0a9e45c0a5be48d29888e87a27ff48d0f966 (patch)
treec89ab51a97f81d5e3a6679839733f260893e8f08 /web/template
parentf7f5152be5abd9977301363f80fe596907021c8b (diff)
downloadaur-58aa0a9e45c0a5be48d29888e87a27ff48d0f966.tar.gz
aur-58aa0a9e45c0a5be48d29888e87a27ff48d0f966.tar.xz
Copy Git repository URL on click
The Git repository URLs are not meant to be visited using a web browser. Copy the link to the clipboard instead. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/template')
-rw-r--r--web/template/pkg_details.php17
-rw-r--r--web/template/pkgbase_details.php17
2 files changed, 30 insertions, 4 deletions
diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php
index 93b5f1e5..c6bb32d8 100644
--- a/web/template/pkg_details.php
+++ b/web/template/pkg_details.php
@@ -100,9 +100,9 @@ $base_uri = get_pkgbase_uri($row['BaseName']);
<tr>
<th><?= __('Git Clone URL') . ': ' ?></th>
<td>
- <a href="<?= $git_clone_uri_anon ?>"><?= $git_clone_uri_anon ?></a> (<?= __('read-only') ?>)
+ <a class="copy" href="<?= $git_clone_uri_anon ?>"><?= $git_clone_uri_anon ?></a> (<?= __('read-only') ?>, <?= __('click to copy') ?>)
<?php if (in_array($uid, $maintainers)): ?>
- <br /> <a href="<?= $git_clone_uri_priv ?>"><?= $git_clone_uri_priv ?></a>
+ <br /> <a class="copy" href="<?= $git_clone_uri_priv ?>"><?= $git_clone_uri_priv ?></a> (<?= __('click to copy') ?>)
<?php endif; ?>
</td>
</tr>
@@ -306,3 +306,16 @@ endif;
<?php endif; ?>
</div>
</div>
+
+<script>
+$(document).ready(function() {
+ $('.copy').click(function(e) {
+ var tmp = $("<input>");
+ $("body").append(tmp);
+ tmp.val($(this).text()).select();
+ document.execCommand("copy");
+ tmp.remove();
+ e.preventDefault();
+ });
+});
+</script>
diff --git a/web/template/pkgbase_details.php b/web/template/pkgbase_details.php
index b2ce8cbe..a6857c4e 100644
--- a/web/template/pkgbase_details.php
+++ b/web/template/pkgbase_details.php
@@ -49,9 +49,9 @@ $base_uri = get_pkgbase_uri($row['Name']);
<tr>
<th><?= __('Git Clone URL') . ': ' ?></th>
<td>
- <a href="<?= $git_clone_uri_anon ?>"><?= $git_clone_uri_anon ?></a> (<?= __('read-only') ?>)
+ <a class="copy" href="<?= $git_clone_uri_anon ?>"><?= $git_clone_uri_anon ?></a> (<?= __('read-only') ?>, <?= __('click to copy') ?>)
<?php if (in_array($uid, $maintainers)): ?>
- <br /> <a href="<?= $git_clone_uri_priv ?>"><?= $git_clone_uri_priv ?></a>
+ <br /> <a class="copy" href="<?= $git_clone_uri_priv ?>"><?= $git_clone_uri_priv ?></a> (<?= __('click to copy') ?>)
<?php endif; ?>
</td>
</tr>
@@ -135,3 +135,16 @@ endif;
</div>
</div>
</div>
+
+<script>
+$(document).ready(function() {
+ $('.copy').click(function(e) {
+ var tmp = $("<input>");
+ $("body").append(tmp);
+ tmp.val($(this).text()).select();
+ document.execCommand("copy");
+ tmp.remove();
+ e.preventDefault();
+ });
+});
+</script>