From f1d5d2edd76ef14feb8d455723236c461733578a Mon Sep 17 00:00:00 2001 From: Andreas Monitzer Date: Sun, 2 Oct 2016 02:08:04 +0200 Subject: [PATCH 1/2] Preserve websocket server IP over reloading the web page. --- webrepl.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webrepl.html b/webrepl.html index a2b8cda..7c17d22 100644 --- a/webrepl.html +++ b/webrepl.html @@ -97,6 +97,10 @@ (function() { window.onload = function() { + var url = window.location.hash.substring(1); + if(url) { + document.getElementById('url').value = 'ws://' + url; + } var size = calculate_size(self); term = new Terminal({ cols: size[0], @@ -134,6 +138,7 @@ } function connect(url) { + window.location.hash = url.substring(5); ws = new WebSocket(url); ws.binaryType = 'arraybuffer'; ws.onopen = function() { From 8962e14f08e7e83da84dc51f7e3acb6c6a98a96b Mon Sep 17 00:00:00 2001 From: Andreas Monitzer Date: Wed, 26 Oct 2016 10:17:27 +0200 Subject: [PATCH 2/2] Fix indentation. --- webrepl.html | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/webrepl.html b/webrepl.html index 7c17d22..f757c34 100644 --- a/webrepl.html +++ b/webrepl.html @@ -97,19 +97,19 @@ (function() { window.onload = function() { - var url = window.location.hash.substring(1); - if(url) { - document.getElementById('url').value = 'ws://' + url; - } - var size = calculate_size(self); - term = new Terminal({ - cols: size[0], - rows: size[1], - useStyle: true, - screenKeys: true, - cursorBlink: false - }); - term.open(document.getElementById("term")); + var url = window.location.hash.substring(1); + if(url) { + document.getElementById('url').value = 'ws://' + url; + } + var size = calculate_size(self); + term = new Terminal({ + cols: size[0], + rows: size[1], + useStyle: true, + screenKeys: true, + cursorBlink: false + }); + term.open(document.getElementById("term")); }; window.addEventListener('resize', function() { var size = calculate_size(self);