Js improvements

This improves a bit the JS by fixing some of my comments in 7ba9af8be9986d87a9d536a09f7ed5ef4d1cbb8e (and adding TODOs for the remaining ones requiring more work)
It also fixes the parsing of the HTML for prototypes for jQuery 1.9+ when the prototype does not start with a ``<`` (because of leading spaces for instance). Note that this change bumps the jQuery requirement to 1.8+