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.

flashing alert
#1
Smile Hello
Did anyone make a flashing alert by Scrip?
Someone can help or send a scrap, of course in no-alert mode, the flicker stops. Regards
Reply
#2
Do you want to do this in standard visualization or Mosaic? What kind of alert do you want - an icon or text label? What type is the alert object - 1 bit or something else?
Reply
#3
(28.09.2021, 05:45)admin Wrote: Do you want to do this in standard visualization or Mosaic? What kind of alert do you want - an icon or text label? What type is the alert object - 1 bit or something else?

Greetings Smile

Thanks for the reply I want an alert in the icon, in 1 bit, I did not understand what is visualization or Mosaic. I work in a visualization screen. Thanks
Reply
#4
You can do it with a transparent picture if there is no problem
and a animated gif with to pictures in it, 1 transparent and one with symbol of problem you want.

something like this
[Image: Alert.gif]
sourch: https://commons.wikimedia.org/wiki/File:Alert.gif
Reply
#5
Animated GIF is an easy solution.
This can also be achieved with Custom JavaScript. This example will show/hide all elements with additional class set to alert every second when 0/1/24 value is set to true. You can also change $('.alert').removeClass('hide'); to $('.alert').addClass('hide'); to hide the element when the object value is false.

Code:
$(function(){
  if (window.grp) {
    var timer;
    
    grp.listen('0/1/24', function(object) {
      if (object.value) {
        if (!timer) {
          timer = setInterval(function() {
            $('.alert').toggleClass('hide');
          }, 1000);
        }
      }
      else {
        $('.alert').removeClass('hide');
        clearInterval(timer);
        timer = null;
      }
    });
  };
});
Reply
#6
(29.09.2021, 06:12)admin Wrote: Animated GIF is an easy solution.
This can also be achieved with Custom JavaScript. This example will show/hide all elements with additional class set to alert every second when 0/1/24 value is set to true. You can also change $('.alert').removeClass('hide'); to $('.alert').addClass('hide'); to hide the element when the object value is false.

Code:
$(function(){
  if (window.grp) {
    var timer;
   
    grp.listen('0/1/24', function(object) {
      if (object.value) {
        if (!timer) {
          timer = setInterval(function() {
            $('.alert').toggleClass('hide');
          }, 1000);
        }
      }
      else {
        $('.alert').removeClass('hide');
        clearInterval(timer);
        timer = null;
      }
    });
  };
});

great and easy, alternative to creating GIF.

But how to make it depend on the element value (Binary) instead of a specific object?
Best Regards,
Reply
#7
You can find the mapped group address like this: https://forum.logicmachine.net/showthrea...5#pid20275
Reply
#8
(29.09.2021, 08:16)admin Wrote: You can find the mapped group address like this: https://forum.logicmachine.net/showthrea...5#pid20275

Thank you admin for advising me to do it by myself.

This is what I did is there any advice?

Code:
// Flashing Alert

$(function(){

    $('.alert').each(function(_, el) {
    var timer;
    var addr = $(el).data('object');
    if (addr) {
 
  grp.listen(addr, function(obj) {

      if (obj.value) {
        if (!timer) {
          timer = setInterval(function() {
            $('.alert').toggleClass('hide');
          }, 500);
        }
      }
      else {
        $('.alert').removeClass('hide');
        clearInterval(timer);
        timer = null;
      }
    });
  };
});
});
Best Regards,
Reply
#9
(29.09.2021, 10:22)khalil Wrote:
(29.09.2021, 08:16)admin Wrote: You can find the mapped group address like this: https://forum.logicmachine.net/showthrea...5#pid20275

Thank you admin for advising me to do it by myself.

This is what I did is there any advice?

Code:
// Flashing Alert

$(function(){

    $('.alert').each(function(_, el) {
    var timer;
    var addr = $(el).data('object');
    if (addr) {
 
  grp.listen(addr, function(obj) {

      if (obj.value) {
        if (!timer) {
          timer = setInterval(function() {
            $('.alert').toggleClass('hide');
          }, 500);
        }
      }
      else {
        $('.alert').removeClass('hide');
        clearInterval(timer);
        timer = null;
      }
    });
  };
});
});

Thanks for the answers I will try thanks Smile
Reply
#10
If you reference $('.alert') further in the code this means that all elements with alert class will be flashed if at least one objects is set to true. So it won't work for multiple/different alert objects. Try this (not tested):
Code:
$(function() {
  $('.alert').each(function(_, el) {
    var $el = $(el);
    var addr = $el.data('object');
    var timer;

    if (addr) {
      grp.listen(addr, function(obj) {
        if (obj.value) {
          if (!timer) {
            timer = setInterval(function() {
              $el.toggleClass('hide');
            }, 500);
          }
        }
        else {
          $el.removeClass('hide');
          clearInterval(timer);
          timer = null;
        }
      });
    }
  });
});
Reply
#11
(29.09.2021, 10:36)admin Wrote: If you reference $('.alert') further in the code this means that all elements with alert class will be flashed if at least one objects is set to true. So it won't work for multiple/different alert objects. Try this (not tested):
Code:
$(function() {
  $('.alert').each(function(_, el) {
    var $el = $(el);
    var addr = $el.data('object');
    var timer;

    if (addr) {
      grp.listen(addr, function(obj) {
        if (obj.value) {
          if (!timer) {
            timer = setInterval(function() {
              $el.toggleClass('hide');
            }, 500);
          }
        }
        else {
          $el.removeClass('hide');
          clearInterval(timer);
          timer = null;
        }
      });
    }
  });
});

That's right, I didn't notice that because I tested it on one object

your script seems to work fine, I tested it for two objects and work fine
Best Regards,
Reply
#12
(29.09.2021, 06:12)admin Wrote: Animated GIF is an easy solution.
This can also be achieved with Custom JavaScript. This example will show/hide all elements with additional class set to alert every second when 0/1/24 value is set to true. You can also change $('.alert').removeClass('hide'); to $('.alert').addClass('hide'); to hide the element when the object value is false.

Code:
$(function(){
  if (window.grp) {
    var timer;
   
    grp.listen('0/1/24', function(object) {
      if (object.value) {
        if (!timer) {
          timer = setInterval(function() {
            $('.alert').toggleClass('hide');
          }, 1000);
        }
      }
      else {
        $('.alert').removeClass('hide');
        clearInterval(timer);
        timer = null;
      }
    });
  };
});


Hello

I entered the script but I have a lot of error messages you can check it again thanks
? p.s  my object 1/7/20  thanks
Reply
#13
(29.09.2021, 19:53)Nir70 Wrote:
(29.09.2021, 06:12)admin Wrote:
Code:
$(function(){
  if (window.grp) {
    var timer;
   
    grp.listen('0/1/24', function(object) {
      if (object.value) {
        if (!timer) {
          timer = setInterval(function() {
            $('.alert').toggleClass('hide');
          }, 1000);
        }
      }
      else {
        $('.alert').removeClass('hide');
        clearInterval(timer);
        timer = null;
      }
    });
  };
});


Hello

I entered the script but I have a lot of error messages you can check it again thanks
? p.s  my object 1/7/20  thanks

I used the script and its works fine.
do you insert the script in the custom JavaScript page: Scripting> Tools> Edit custom JavaScript
Best Regards,
Reply
#14
(30.09.2021, 07:00)khalil Wrote:
(29.09.2021, 19:53)Nir70 Wrote:
(29.09.2021, 06:12)admin Wrote:
Code:
$(function(){
  if (window.grp) {
    var timer;
   
    grp.listen('0/1/24', function(object) {
      if (object.value) {
        if (!timer) {
          timer = setInterval(function() {
            $('.alert').toggleClass('hide');
          }, 1000);
        }
      }
      else {
        $('.alert').removeClass('hide');
        clearInterval(timer);
        timer = null;
      }
    });
  };
});


Hello

I entered the script but I have a lot of error messages you can check it again thanks
? p.s  my object 1/7/20  thanks

I used the script and its works fine.
do you insert the script in the custom JavaScript page: Scripting> Tools> Edit custom JavaScript
Thanks, I inserted the scrap as you just said. How now I enable it after inserting a JavaScript page: Scripting> Tools> Edit custom JavaScript?
Reply
#15
[quote pid="23203" dateline="1632991948"]
Thanks, I inserted the scrap as you just said. How now I enable it after inserting a JavaScript page: Scripting> Tools> Edit custom JavaScript?
[/quote]

Just save
To see the effect you should open the PC/Tablet Page if you are using SL or W4KNX.
you will not see the effect on the visualization editor page.
Best Regards,
Reply
#16
(30.09.2021, 09:00)khalil Wrote: [quote pid="23203" dateline="1632991948"]
Thanks, I inserted the scrap as you just said. How now I enable it after inserting a JavaScript page: Scripting> Tools> Edit custom JavaScript?

Just save
To see the effect you should open the PC/Tablet Page if you are using SL or W4KNX.
you will not see the effect on the visualization editor page.
[/quote]

Hi, I'm not a JAWA expert. Do I need to add value / object to what you sent? I tried through the screen non-flashing visual, I just need a sample object 1/7/10 (1 bit) in the sample problem so it flashes at about 0 it does not flash. Thanks Cool
Reply
#17
Use this code
https://forum.logicmachine.net/showthrea...3#pid23183
and add additional calss 'alert' to your object in visu editor.
------------------------------
Ctrl+F5
Reply
#18
(28.09.2021, 17:13)Dré Wrote: You can do it with a transparent picture if there is no problem
and a animated gif with to pictures in it, 1 transparent and one with symbol of problem you want.

something like this
[Image: Alert.gif]
sourch: https://commons.wikimedia.org/wiki/File:Alert.gif

hello
Thank you very much, is this an icon you created? Can I create or change captions myself? ERRO for example? Regards
Reply
#19
Create two images and convert them to gif, there are loads of sw available for example this https://imgflip.com/gif-maker
------------------------------
Ctrl+F5
Reply
#20
(28.09.2021, 17:13)Dré Wrote: You can do it with a transparent picture if there is no problem
and a animated gif with to pictures in it, 1 transparent and one with symbol of problem you want.

something like this
[Image: Alert.gif]
sourch: https://commons.wikimedia.org/wiki/File:Alert.gif

I tried thanks I took the same symbol (Alert) but the flicker disappeared
Reply


Forum Jump: