Convert Php Function To Javascript Editor