Okay
  Public Ticket #2220458
Webhooks
Closed

Comments

  • Martynas started the conversation

    Hello, I want to hide attending people in events. Didn't found in code where it lays so I thought the best way is to remove by simple JS text removal. 

    I have added delay after site is loaded, find element and remove text I want. But problem it loads different time everytime. So I thought maybe there is somekind of event that I can hook my custom listener?

    Example what I did:
    ```

    document.addEventListener("DOMContentLoaded", function(e) {
      setTimeout(function() {
          var capacities = document.getElementsByClassName("am-event-sub-info-capacity");
          for (let item of capacities) {
            var price = item.innerText;
            price = price.slice(0, 11) + price.slice(15,20);
            item.innerText = price;
          }
      }, 2000);
    });

    ```

  • [deleted] replied

    Hello Martynas, 

    Could you please tell me where exactly do you want to hide this? Thanks!

  • Martynas replied

    Attached image to show what exactly I want to hide

  • [deleted] replied

    Hello Martynas,

    Please add this script to the page where you have Amelia shortcode: 

    <script>
    window.ameliaBooking = {
    replaceText: function () {
    var elements = document.getElementsByClassName('am-event-sub-info-capacity') if (elements.length && ameliaIntervalId) {
    clearInterval(ameliaIntervalId)
    } for (var i = 0; i < elements.length; i++) {
    var elementImg = elements[i].getElementsByTagName('img')[0]
    var elementText = elements[i].textContent var str1 = elementText.substr(0, elementText.lastIndexOf(":"))
    var str2 = elementText.substr(elementText.lastIndexOf("/") + 1) var textNode = document.createTextNode(str1 + str2) elements[i].innerHTML = ''
    elements[i].appendChild(elementImg)
    elements[i].appendChild(textNode)
    }
    }
    }var ameliaIntervalId = setInterval(window.ameliaBooking.replaceText, 500)
    </script>

    And let me know if it worked. Thanks!

  • Martynas replied

    Yes it did worked! Thank you!

  • [deleted] replied

    Great, glad to hear that !

    You are welcome. 

    If you have any other questions or concerns feel free to open a new ticket and we will gladly help,