Move the HUD to an iframe and handle find mode in it

This PR
* moves the HUD to an iframe
* moves find mode key handling to the iframe
* changes the normal HUD to a `contentEditable` element for find mode
* tidies up some frontend code.

In terms of issues, this
* fixes #1266 
* fixes (possibly) #576 
* fixes #556 (and so also #1013, #416, #498 and #1103 which were closed in favour of it).