27.02.2024, 16:25
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 !
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);
});