Update main.js

Check to ensure document exists before opening full dialog