Minor refactor of open file JS.