javascript substring indexof to end