Proper https support

This commit is contained in:
Aleksandr Zykov 2015-05-07 08:31:28 +02:00
parent 45f3772a9c
commit 2c75c394d3
1 changed files with 7 additions and 3 deletions

View File

@ -1173,11 +1173,15 @@ jQuery.extend( jQuery.easing,
})();
if (window.server_url) {
ws_url = "ws://" + (window.server_url.replace('http://', '')) + "/Websocket?wrapper_key=" + window.wrapper_key;
var origin = window.server_url || window.location.origin;
var proto;
if (origin.indexOf('https:') === 0) {
proto = { ws: 'wss', ht: 'https' };
} else {
ws_url = "ws://" + window.location.hostname + ":" + window.location.port + "/Websocket?wrapper_key=" + window.wrapper_key;
proto = { ws: 'ws', ht: 'http' };
}
console.log(origin, proto)
ws_url = proto.ws + ":" + (origin.replace(proto.ht + ':', '')) + "/Websocket?wrapper_key=" + window.wrapper_key;
window.wrapper = new Wrapper(ws_url);