Python Function Inside Function Javascript Code