fix popup bugs. refactor javascripts.