Logic Machine Forum
flashing alert - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: flashing alert (/showthread.php?tid=3590)



flashing alert - Nir70 - 28.09.2021

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


RE: flashing alert - admin - 28.09.2021

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?


RE: flashing alert - Nir70 - 28.09.2021

(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


RE: flashing alert - Dré - 28.09.2021

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


RE: flashing alert - admin - 29.09.2021

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;
      }
    });
  };
});



RE: flashing alert - khalil - 29.09.2021

(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?


RE: flashing alert - admin - 29.09.2021

You can find the mapped group address like this: https://forum.logicmachine.net/showthread.php?tid=1976&pid=20275#pid20275


RE: flashing alert - khalil - 29.09.2021

(29.09.2021, 08:16)admin Wrote: You can find the mapped group address like this: https://forum.logicmachine.net/showthread.php?tid=1976&pid=20275#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;
      }
    });
  };
});
});



RE: flashing alert - Nir70 - 29.09.2021

(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/showthread.php?tid=1976&pid=20275#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


RE: flashing alert - admin - 29.09.2021

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;
        }
      });
    }
  });
});



RE: flashing alert - khalil - 29.09.2021

(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


RE: flashing alert - Nir70 - 29.09.2021

(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


RE: flashing alert - khalil - 30.09.2021

(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


RE: flashing alert - Nir70 - 30.09.2021

(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?


RE: flashing alert - khalil - 30.09.2021

[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.


RE: flashing alert - Nir70 - 30.09.2021

(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


RE: flashing alert - Daniel - 30.09.2021

Use this code
https://forum.logicmachine.net/showthread.php?tid=3590&pid=23183#pid23183
and add additional calss 'alert' to your object in visu editor.


RE: flashing alert - Nir70 - 06.10.2021

(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


RE: flashing alert - Daniel - 06.10.2021

Create two images and convert them to gif, there are loads of sw available for example this https://imgflip.com/gif-maker


RE: flashing alert - Nir70 - 06.10.2021

(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