js: Relative instead of absolute addresses

window.location redirection and XMLHttpRequest use relative addresses
js: Refactor, remove tabs

Refactor, mainly replace tabs with spaces and fix indentation.