Refactor card drawing into external js file