Update JavaScript for live trial

After refactoring the calc code, this is the updated javascript