HEX
Server: Apache
System: Linux web15f74.uni5.net 5.4.282-1.el8.elrepo.x86_64 #1 SMP Mon Aug 19 18:33:22 EDT 2024 x86_64
User: lucendi (859622)
PHP: 7.4.33
Disabled: apache_child_terminate,c99_buff_prepare,c99_sess_put,dl,exec,leak,link,myshellexec,openlog,passthru,pclose,pcntl_exec,php_check_syntax,php_strip_whitespace,popen,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,symlink,system,socket_listen,socket_create_listen,putenv
Upload Files
File: /home/lucendi/www/wp-content/plugins/creame-whatsapp-me/admin/js/joinchat.js
(function ($, window) {
  'use strict';

  $(function () {
    var has_iti = typeof intlTelInput === 'function' && window.intl_tel_l10n;
    var $phone = $('#joinchat_phone');

    if (has_iti) {
      // Set intlTelInput config (make global)
      var country_request = JSON.parse(localStorage.joinchat_country_code || '{}');
      var country_code = (country_request.code && country_request.date == new Date().toDateString()) ? country_request.code : false;

      // Capture placeholder (global settings phone)
      var global_phone = $phone.attr('placeholder') || '';

      window.joinchat_intl_tel_config = {
        hiddenInput: () => { return { phone: $phone.data('name') || 'joinchat[telephone]' }; },
        strictMode: true,
        separateDialCode: true,
        initialCountry: country_code || 'auto',
        geoIpLookup: country_code ? null : (success, failure) => {
          fetch("https://ipapi.co/json")
            .then((res) => res.json())
            .then((data) => {
              localStorage.joinchat_country_code = JSON.stringify({ code: data.country_code, date: new Date().toDateString() });
              success(data.country_code);
            }).catch(() => failure());
        },
        autoPlaceholder: 'aggressive',
        customPlaceholder: (country_ph) => global_phone || `${intl_tel_l10n.placeholder} ${country_ph}`,
        i18n: intl_tel_l10n,
      };

      // Apply intlTelInput to phone input
      if ($phone.length) {
        var iti = intlTelInput($phone[0], joinchat_intl_tel_config);
        // Placeholder phone format and reset to initial value
        iti.promise.then(() => {
          if (global_phone === '') return;

          const phone = $phone.val();
          iti.setNumber(global_phone);
          global_phone = iti.getNumber(intlTelInput.utils.numberFormat.NATIONAL);
          iti.setNumber(phone);
          iti.setPlaceholderNumberType("MOBILE"); // Trigger placeholder update
        });

        $phone.on('open:countrydropdown', () => { global_phone = null; });
        $phone.on('input countrychange', function () {
          $(this).css('color', this.value.trim() && !iti.isValidNumber(true) ? '#ca4a1f' : '');
          // Ensures number it's updated on AJAX save (Gutemberg)
          iti.ui.hiddenInput.value = iti.getNumber();
        });
      }
    }
  });
})(jQuery, window);