update demo page to reduce js duplication