This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

JavaScript Functions Integration
#1
Hey everyone,

I'm currently employing two JavaScript functions to showcase alarms on the SCADA page.
They're functioning well individually. However, when one function triggers an alarm and then the other one does too, it seems like only the most recent alarm stays visible.
I don't know how to merge both functions to ensure all alarms display properly.

Any help?

Thanks in advance !

Code:
$(function() {
  if (typeof grp != 'object') {
    return;
  }

  function updat() {
    var text = [];
    var currentDate = new Date().toLocaleString();
    var alarmsExiste = true;

    $.each(grp.tag('ahu'), function(id, object) {
      if (object.value === false) {
        text.push('<span class="blink">'+  object.name + " is Offline" + '</span>');
        alarmsExiste = true;
      }
    });

   if (alarmsExiste) {
      $('.alarm').css({
        'white-space': 'pre',
        'position': 'relative',
        'left': '25px',
        'top': '40px'
       
      }).html(text.join('<br>'));
    }
  }

  grp.taglisten('ahu', updat, true);
});

Code:
$(function() {
  if (typeof grp != 'object') {
    return;
  }

  function update() {
    var text = [];
    var currentDate = new Date().toLocaleString();
    var alarmsExist = true;

    $.each(grp.tag('alarm'), function(id, object) {
      if (object.value) {
        text.push('<span class="blink">'+  object.name + '</span>');
        alarmsExist = true;
      }
    });
    if (alarmsExist) {
    $('.alarm').css('white-space', 'pre').html(text.join('<br>'));
  } }
   

  grp.taglisten('alarm', update, true);
});
Reply


Messages In This Thread
JavaScript Functions Integration - by Fahd - 27.02.2024, 16:25

Forum Jump: