js and jq extracted from html and refactored