Move code form controller to HTML5 for switch view