use location object and allow for seamless HTTPS WebSockets

First and foremost, this removes the dependency on a global SERVER_IP constant, instead relying on location.host.

This also checks location.protocol and actually makes the WebSockets work over HTTPS.