merge  popup & refactor js