xref: /webtrees/resources/views/modules/share-url/share.phtml (revision 2ebcf907ed34213f816592af04e6c160335d6311)
1<?php
2
3use Fisharebest\Webtrees\GedcomRecord;
4use Fisharebest\Webtrees\I18N;
5
6/** @var GedcomRecord $record */
7
8?>
9<div class="input-group mb-3">
10    <span class="input-group-text"><?= I18N::translate('URL') ?></span>
11
12    <input type="text" class="form-control" aria-label="" value="<?= e($record->url()) ?>" readonly="readonly" id="share-url-input">
13
14    <button class="btn btn-primary" type="button" id="share-url-button">
15        <?= view('icons/copy') ?>
16        <?= I18N::translate('Copy') ?>
17    </button>
18</div>
19
20<script>
21    document.getElementById('share-url-button').addEventListener('click', function () {
22        const input = document.getElementById('share-url-input');
23        if (navigator.clipboard) {
24            navigator.clipboard.writeText(input.value);
25        } else {
26            input.select();
27            document.execCommand("copy");
28        }
29        alert(<?= json_encode(I18N::translate('The URL was copied to the clipboard')) ?>);
30    });
31</script>
32