xref: /webtrees/resources/views/modules/share-url/share.phtml (revision 22f8fb7c6098ae6368f58ac86748cdeac45f029b)
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    <div class="input-group-prepend">
11        <span class="input-group-text"><?= I18N::translate('URL') ?></span>
12    </div>
13
14    <input type="text" class="form-control" aria-label="" value="<?= e($record->url()) ?>" readonly="readonly" id="share-url-input">
15
16    <div class="input-group-append">
17        <button class="btn btn-primary" type="button" id="share-url-button"><?= view('icons/copy') ?><?= I18N::translate('Copy') ?></button>
18    </div>
19</div>
20
21<script>
22    document.getElementById('share-url-button').addEventListener('click', function () {
23        const url = document.getElementById('share-url-input').value;
24        navigator.clipboard.writeText(url);
25        alert(<?= json_encode(I18N::translate('The URL was copied to the clipboard')) ?>);
26    });
27</script>
28