HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: 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,
Upload Files
File: /var/www/zaklada/html/lib/js/core/message-form.js
(function ($) {
  $(document).ready(function () {
    const createMessageForm = $("#create-message-form");
    const createMessageSubmitButton = $('.js-hearts-input-button');
    const createMessageTextarea = $('.js-hearts-input-textarea');
    const gReCaptcha = $('.js-g-recaptcha');
    const responseRecheck = $('.js-hearts-input-verify-robot');
    const responseError = $('.js-hearts-input-error');
    const responseSuccess = $('.js-hearts-input-success');
        
    function getField(fieldName){
      return $(createMessageForm.find('[name="' + fieldName + '"]'));

    }
    createMessageForm.find('[name="msg"]').keydown ( function (e) {
      //list of functional/control keys that you want to allow always
      var keys = [8, 9, 16, 17, 18, 19, 20, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 144, 145];
      if(e.currentTarget.value != "") {
        gReCaptcha.slideDown('fast');
        responseRecheck.hide();
        responseError.hide();
        responseSuccess.hide();
        createMessageSubmitButton.attr("disabled", false);
      }

      if( $.inArray(e.keyCode, keys) == -1) {
        if (checkMaxLength ($(this).val(), 320)) {
          e.preventDefault();
          e.stopPropagation();
        }
      }
    });

    function checkMaxLength (text, max) {
      return (text.length >= max);
    }

    var formSending = false;
    var sendMessage = function () {
      if(formSending) {
        return;
      }
      var customLoader = $(".custom-loader");

      $(customLoader).css("display", "flex");

      var publicData = null;
      if($("[name='publicData']:checked").length > 0){
        publicData = $("[name='publicData']:checked").val();
      }

      formSending = true;

      var message_content = getField("msg").val();
      
      $.ajax({
        type: "POST",
        dataType: "json",
        url: ajaxurl,
        data: {
          action: "create_message",
          message_content: message_content,

        },
        success: function (data) {
          if (data.success) {   
            createMessageForm.slideUp(function(){   
              responseSuccess.fadeIn();
            });  
            createMessageSubmitButton.attr("disabled", true);
            
          }else{
            responseSuccess.hide();
            responseError.slideDown('fast');
          }
          formSending = false;
          $(customLoader).hide();
        },
        error: function(data){
          responseError.slideDown('fast');  
          responseSuccess.hide(); 
        }
      });
    };

  createMessageForm.submit(function (event) {
    event.preventDefault();
    $.post(
      themeurl + "/validate.php",
      createMessageForm.serialize(),
      function (data) {
        if (data.result == "success") {
          sendMessage();
        } else {  
          responseRecheck.slideDown('fast');      
        }
      },
      "json"
    ).fail(function () {
      responseSuccess.hide();
      responseError.slideDown('fast');  
    });
  });
    

    $("[name='paymentType']").click(function (e) {
      if ($(".payment-type__content.show").length) {
        $(".payment-type__content.show").hide();
        $(".payment-type__content.show").removeClass("show");
        var elementId = $(e.currentTarget).attr("id");
        $("#" + elementId + "Details").show();
        $("#" + elementId + "Details").addClass("show");
      } else {
        var elementId = $(e.currentTarget).attr("id");
        $("#" + elementId + "Details").show();
        $("#" + elementId + "Details").addClass("show");
      }
    });
  });
})(jQuery);