foundryvtt-simple-calendar icon indicating copy to clipboard operation
foundryvtt-simple-calendar copied to clipboard

[QUESTION] Check if Calendar is already open before `showCalendar();`

Open mouse0270 opened this issue 2 years ago • 1 comments

What is the best way to check and see if the calendar window is already open before calling SimpleCalendar.api.showCalendar(); It appears that this currently causes the calendar to register all its render hooks with some modules don't play nicely with. I'd like to check and see if the calendar is already open before calling this function and just curious the best way to handle that.

mouse0270 avatar Nov 12 '22 15:11 mouse0270

I don't have anything in the API to check if the Simple Calendar application is open or not.

For a quick check you could do something like this function isSCOpen(){return !!Array.from(document.querySelectorAll('div[id^="fsc-"].simple-calendar')).filter(e => {return !e.querySelector('.window-resizable-handle')}).length;}

Then it is a simple function call to isScOpen() and that will return a Boolean of if the dialog is open or not.

vigoren avatar Nov 13 '22 00:11 vigoren

In version 2.1.73 I have added the API function SimpleCalendar.api.isOpen() that will return if the calendar is open or not.

vigoren avatar Jan 27 '23 06:01 vigoren