Fixes and enhances javascript websocket url function.

Fixes wrong previous commit. Websocket URL is now based on the path before the anchor, appended by '/ws'. Still works with the original C backend, also works when running on subpaths.