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