Logic Machine Forum
Run an Event Script with Page Name - 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: Run an Event Script with Page Name (/showthread.php?tid=3311)



Run an Event Script with Page Name - savaskorkmaz - 23.04.2021

Hi,
I have an event scripts like :
Event Script for Floor 1
Event Script for Floor 2

and also i have pages like :

Floor 1
Floor 2

I need that if user open Floor 1 in visualation, event script "Event Script for Floor 1" will run once.

How can i do that ?

Regards,


RE: Run an Event Script with Page Name - admin - 23.04.2021

If you are referring to Mosaic then this is not possible because it does not have Custom JavaScript support. In standard visualization there's a showplan event that is triggered when a new plan is opened. See this: https://forum.logicmachine.net/showthread.php?tid=2870&pid=20146#pid20146


RE: Run an Event Script with Page Name - savaskorkmaz - 26.04.2021

(23.04.2021, 12:19)admin Wrote: If you are referring to Mosaic then this is not possible because it does not have Custom JavaScript support. In standard visualization there's a showplan event that is triggered when a new plan is opened. See this: https://forum.logicmachine.net/showthread.php?tid=2870&pid=20146#pid20146

Hi,

In that example, if a new plan is opened, script orients to otherplan. I dont want to orient the page to other plan. I need to run an event script instead of orienting to other plan. Can you help for this specific need please ?


RE: Run an Event Script with Page Name - admin - 26.04.2021

Change plan IDs, group addresses and values as needed.
Code:
$(function(){
  if (typeof grp == 'undefined') {
    return;
  }
  
  $('body').on('showplan', function(event, id) {
    if (id == 2) {
      grp.write('0/0/1', 50);
    }
    else if (id == 3) {
      grp.write('0/0/1', 90);
    }
  }).trigger('showplan', [ currentPlanId ]);
});