I would not encourage using script tags inside HTML, it blocks the page parsing. You either use custom data attributes or hidden input fields to store these values in HTML
Also, I am not sure why you are using JS Use API to get dialog fields. Use API is slower as compare to java sling model or expression in sightly as it executes twice (JS Rhino -> Java -> Compile). See if you can avoid it.