refactoring ui.js into module exposed to game client