Przeglądaj źródła

Use encrypted websocket if connected via https

Lucas Stadler 9 lat temu
rodzic
commit
7d4bd2f1d6
1 zmienionych plików z 2 dodań i 1 usunięć
  1. 2 1
      js/pixl/public/index.html

+ 2 - 1
js/pixl/public/index.html

@ -200,7 +200,8 @@
200 200
201 201
		pixl.online = false;
202 202
		pixl.connect = function() {
203
			pixl.ws = new WebSocket('ws://' + (location.host || 'localhost:8001') + '/ws');
203
			var protocol = location.protocol == 'https:' ? 'wss://' : 'ws://';
204
			pixl.ws = new WebSocket(protocol + (location.host || 'localhost:8001') + '/ws');
204 205
			pixl.ws.onopen = function() {
205 206
				pixl.online = true;
206 207
				pixl.status.online.style.backgroundColor = "green";