I have a javascript function (function1) that checks some global variables (can the user connect, is the service available, etc) before calling another (legacy) function (function2) that actually pops a window and connects the user to our service. I want to prevent function2 from being called anywhere but from function1. Is this possible?
As a cheap solution, I figured I could emit a variable from function1 and check for it in function2 before executing. Is there another way? Is there a way to find out the calling element/method in a javascript function?