Fix coding style in /web

This PR mainly adds braces to single line statements, and it also fixes a few indentation errors.

@timvandermeij Unfortunately this isn't covered by the tests, so you will have to go through it very carefully line by line. Sorry about that!
I've tested this PR by using the viewer when browsing through a few PDFs, but please test this too. (E.g. check that text selection and searching works as before.)