VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/webtrees/resources/views/edit/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/webtrees/resources/views/edit/input-addon-edit-name.phtml
<?php

declare(strict_types=1);

use Fisharebest\Webtrees\I18N;

/**
 * @var string $id
 */

?>

<span class="input-group-text">
    <a id="<?= e($id) ?>-edit" href="#" title="<?= I18N::translate('Edit the name') ?>">
        <?= view('icons/edit') ?>
        <span class="visually-hidden">
            <?= I18N::translate('Edit the name') ?>
        </span>
    </a>
</span>

<script>
  document.getElementById('<?= e($id) ?>-edit').addEventListener('click', function (event) {
    event.preventDefault();
    // Toggle the visibility of the full name inputs
    // Hide the disabled input - does not send any value when posting the form
    let disabledElement = document.getElementById('<?= e($id) ?>-disabled');
    disabledElement.classList.add('d-none');
    // Show the editable input - send value when posting the form
    let editElement = document.getElementById('<?= e($id) ?>');
    editElement.classList.remove('d-none');
    editElement.focus();

    this.parentNode.parentNode.removeChild(this.parentNode);
  });
  document.addEventListener('DOMContentLoaded', function () {
    let NAME = document.getElementById('<?= e($id) ?>');
    let NAME_DISABLED = document.getElementById('<?= e($id) ?>-disabled');
    let container = NAME.parentNode.parentNode.parentNode;

    let setNameValue = function(name_value) {
      NAME.value = name_value;
      NAME_DISABLED.value = name_value;
    }

    if (NAME.id.endsWith('-INDI-NAME')) {
      // NAME has children at the same level.
      container = container.parentNode;
    } else {
      // ROMN/FONE have children in a collapsable panel
      container = container.nextSibling.nextSibling;
    }
    let NPFX = container.querySelector('[id$="-NPFX"]');
    let GIVN = container.querySelector('[id$="-GIVN"]');
    let SPFX = container.querySelector('[id$="-SPFX"]');
    let SURN = container.querySelector('[id$="-SURN"]');
    let NSFX = container.querySelector('[id$="-NSFX"]');

    let generated_name = webtrees.buildNameFromParts(
      NPFX ? NPFX.value : '',
      GIVN ? GIVN.value : '',
      SPFX ? SPFX.value : '',
      SURN ? SURN.value : '',
      NSFX ? NSFX.value : '',
      'U',
    );

    if (NAME.value === '') {
      setNameValue(generated_name);
    }
    if (NAME.value !== generated_name) {
      document.getElementById('<?= e($id) ?>-edit').click();
    } else {
      let fn = function () {
        if (NAME.classList.contains("d-none") === true) {
          setNameValue(webtrees.buildNameFromParts(
            NPFX ? NPFX.value : '',
            GIVN ? GIVN.value : '',
            SPFX ? SPFX.value : '',
            SURN ? SURN.value : '',
            NSFX ? NSFX.value : '',
            'U',
          ));
        }
      };
      NPFX && NPFX.addEventListener('input', fn);
      GIVN && GIVN.addEventListener('input', fn);
      SPFX && SPFX.addEventListener('input', fn);
      SURN && SURN.addEventListener('input', fn);
      SURN && SURN.addEventListener('blur', fn); // For autocompleted entries
      NSFX && NSFX.addEventListener('input', fn);
    }
  });
</script>

VaKeR 2022