Adding section to active page
Hi
I´m trying to create a very simple javascript for adding new section to active page. So far I have made following code:
var myDoc = app.activeDocument;
var numero = app.activeWindow.activePage.name;
var numero2 = numero -1;
myDoc.sections.add(myDoc.pages[numero2]);
It basically works as it should, whren I double-click some page thumbnail in pages panel, that page will become active... and if I run the script at that point it usually adds section to active page pretty nicely....
However, if I use that script with Configurator 2.0 and create a custom panel, with Add a section button (where I have attached that same javascript) InDesign starts to throw me some weird alert:

If I answer yes, script will work as it should, but I would like to make it work so that users won´t get that alert at all....
If I run that scrpt from Scripts panel, it works without alerts...
Another thing I have tried to figure out is how to create some kind of error handler that would stop the script if active page already has a section start, now script generates a javascript error in those cases.... it would be more classy if simply nothing happened....
Any help appreciated.... thanks
