Remove alert html creation logic from javascript file to a template