More tidyup

- Replaced the JS callback handler in HTML with a click handler
attached in the JS
- Replaced the insecure HTML creation with safe jQuery construction
- Took out the space in anonymous function decls