diff --git a/client/index.html b/client/index.html index 8800a8e..9e66033 100644 --- a/client/index.html +++ b/client/index.html @@ -18,7 +18,7 @@ diff --git a/client/js/main.js b/client/js/main.js index 87fd188..437ad22 100644 --- a/client/js/main.js +++ b/client/js/main.js @@ -11,8 +11,8 @@ function resize() { displayWidth = Math.round(maxWidth) displayHeight = Math.round(maxWidth * 0.6) } - canvas.style.width = displayWidth + 'px' - canvas.style.height = displayHeight + 'px' + img.style.width = displayWidth + 'px' + img.style.height = displayHeight + 'px' errorbox.style.width = displayWidth + 'px' errorbox.style.height = displayHeight + 'px' } @@ -22,22 +22,22 @@ function setup() { ws = new WebSocket(localStorage.getItem('url')) ws.onmessage = function(e) { window.m = e - let type, pos, x, y, data, img, code, msg + let type, data, code, msg type = e.data.split('%')[0] if (type == 'ver') { ws.send('pass ' + localStorage.getItem('password')) setInterval(function(){ws.send('ack')}, 3000) } else if ( type == 'pic' ) { data = e.data.split('%')[2] - canvas.src = data + img.src = data errorbox.style.display = 'none' - canvas.style.display = 'block' + img.style.display = 'block' } else if ( type == 'err' ) { code = e.data.split('%')[1] msg = e.data.split('%')[2] errorbox.textContent = msg errorbox.style.display = 'block' - canvas.style.display = 'none' + img.style.display = 'none' console.error('Server reported error: ' + code + ': ' + msg) if (code[0] == '*') { errorbox.innerHTML = msg + '
Please refresh page' @@ -51,12 +51,12 @@ function setup() { ws.onerror = function(e){ errorbox.innerHTML = 'Connection lost
Please refresh page' errorbox.style.display = 'block' - canvas.style.display = 'none' + img.style.display = 'none' } ws.onclose = function(e){ errorbox.innerHTML = 'Connection lost
Please refresh page' errorbox.style.display = 'block' - canvas.style.display = 'none' + img.style.display = 'none' } ws.onopen = function(e) { ws.send('maxver 1') @@ -93,7 +93,7 @@ function connect(e) { } -let canvas = document.querySelector('#canvas') +let img = document.querySelector('#img') let errorbox = document.querySelector('#errorbox') let login = document.querySelector('#login') @@ -114,7 +114,7 @@ let ws resize() window.onresize = resize -canvas.onmousedown = touch -canvas.onmouseup = release +img.onmousedown = touch +img.onmouseup = release start.onclick = connect