refactor js code

fix indendentation, start of pause feature.