refactor js-function click event