refactor take a half-face picture, move javascript code to a file