LogicMachine Forum
Custom JavaScript examples - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: OLD visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: Custom JavaScript examples (/showthread.php?tid=275)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12


RE: Custom JavaScript examples - iridium - 24.07.2024

(24.07.2024, 06:32)admin Wrote: Check this: https://forum.logicmachine.net/showthread.php?tid=2717&pid=17512#pid17512

Thanks


RE: Custom JavaScript examples - danielbrunner1809 - 22.08.2025

Hi,

I would like to implement a haptic feedbak using Visualization on iPhone or Android phones.

Is this pssible with a custom java script?

Thanks and kind regards, Daniel


RE: Custom JavaScript examples - admin - 22.08.2025

See this: https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API
It will only work on Android, Safari on iOS does not support this API.


RE: Custom JavaScript examples - peyoe - 10.02.2026

Hello.
I have a variable that tells me there are new alerts ‘true’.
I would like that when I access the screen where I see the alerts, that variable automatically changes to ‘false’.
Can anyone help me?
Thank you.


RE: Custom JavaScript examples - admin - 10.02.2026

What kind of variable? It is a group address?


RE: Custom JavaScript examples - peyoe - 10.02.2026

A virtual bool one; 50/1/0


RE: Custom JavaScript examples - admin - 10.02.2026

See this: https://forum.logicmachine.net/showthread.php?tid=3311&pid=21463#pid21463


RE: Custom JavaScript examples - peyoe - 10.02.2026

Something like this, keeping in mind that the screen ID is 112 and the variable is 50/1/0:

$(function(){
if (typeof grp == 'undefined') {
return;
}

$('body').on('showplan', function(event, id) {
if (id == 112) {
grp.write('50/1/0', 0);
}
}).trigger('showplan', [ currentPlanId ]);
});


RE: Custom JavaScript examples - peyoe - 11.02.2026

Hi, I've tried the code and it's not working. Could someone help me with this? Thanks in advance.


RE: Custom JavaScript examples - Daniel - 11.02.2026

Which Visualization tool do you use?


RE: Custom JavaScript examples - peyoe - 11.02.2026

(11.02.2026, 12:32)Daniel Wrote: Which Visualization tool do you use?

PC/Tablet


RE: Custom JavaScript examples - admin - 11.02.2026

Change script to this, open browser dev tools (F12) and check what you get in the console. Are you sure that the target plan ID is 112?

Code:
$(function(){
  if (typeof grp == 'undefined') {
    return;
  }
  
  console.log('custom js initialized');

  $('body').on('showplan', function(event, id) {
    console.log('changed to plan', id);

    if (id == 112) {
      grp.write('50/1/0', 0);
    }
  }).trigger('showplan', [ currentPlanId ]);
});



RE: Custom JavaScript examples - Daniel - 11.02.2026

When testing this will work from end visualisation not editor.


RE: Custom JavaScript examples - peyoe - 11.02.2026

Yes, panel ID is 112
And yes, I try it on end visualisation. Still not working.

I have a schnider wiser, I don't know if it is a problem.


RE: Custom JavaScript examples - admin - 11.02.2026

See my previous post, check browser console. Does 50/1/0 exist? Do you have anything else in Custom JS?


RE: Custom JavaScript examples - Daniel - 11.02.2026

Your script works for me on SL, if it doesn't work then it is wrong ID or group.


RE: Custom JavaScript examples - peyoe - 11.02.2026

I have a 50/1/0 address that tells me there are new alerts. The idea I have in mind is that when I access the alerts panel, that variable automatically changes to 0, so that it is assumed that there are no new alerts.


RE: Custom JavaScript examples - Daniel - 11.02.2026

CSS is not JavaScript, check manuals where is the correct place.


RE: Custom JavaScript examples - peyoe - 11.02.2026

(11.02.2026, 13:52)Daniel Wrote: CSS is not JavaScript, check manuals where is the correct place.

Yes, you are absolutely right.
My mistake, I just tested it and the code works correctly.
Thank you very much.