|
|
|
@ -35,42 +35,33 @@ |
|
|
|
|
} else if ("MozWebSocket" in window) { |
|
|
|
|
sock = new MozWebSocket(wsuri); |
|
|
|
|
} else { |
|
|
|
|
log("Browser does not support WebSocket!"); |
|
|
|
|
console.log("Browser does not support WebSocket!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (sock) { |
|
|
|
|
sock.onopen = function() { |
|
|
|
|
log("Connected to " + wsuri); |
|
|
|
|
console.log("Connected to " + wsuri); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sock.onclose = function(e) { |
|
|
|
|
log("Connection closed (wasClean = " + e.wasClean + ", code = " + e.code + ", reason = '" + e.reason + "')"); |
|
|
|
|
console.log("Connection closed (wasClean = " + e.wasClean + ", code = " + e.code + ", reason = '" + e.reason + "')"); |
|
|
|
|
sock = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sock.onmessage = function(e) { |
|
|
|
|
log("Got echo: " + e.data); |
|
|
|
|
console.log("Got echo: " + e.data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function send() { |
|
|
|
|
var msg = document.getElementById('message').value; |
|
|
|
|
var batchsize = parseInt(document.getElementById('batch').value); |
|
|
|
|
if (sock) { |
|
|
|
|
for (var i = 0; i < batchsize; ++i) { |
|
|
|
|
sock.send(document.getElementById("size").value); |
|
|
|
|
} |
|
|
|
|
log("Sent " + batchsize + "x : " + msg); |
|
|
|
|
sock.send(document.getElementById("x-pos").value + "/" + document.getElementById("y-pos").value); |
|
|
|
|
console.log("Sent " + msg); |
|
|
|
|
} else { |
|
|
|
|
log("Not connected."); |
|
|
|
|
console.log("Not connected."); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function log(m) { |
|
|
|
|
ellog.innerHTML += m + '\n'; |
|
|
|
|
ellog.scrollTop = ellog.scrollHeight; |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|
</head> |
|
|
|
|
|
|
|
|
@ -116,7 +107,8 @@ |
|
|
|
|
<br> |
|
|
|
|
<br> |
|
|
|
|
<form class="range-field"> |
|
|
|
|
<input type="range" min="50" max="250" id="size" oninput="send();" value="140" /> |
|
|
|
|
<p>Вертикаль:<input type="range" min="50" max="250" id="y-pos" oninput="send();" value="140" /></p> |
|
|
|
|
<p>Горизонталь:<input type="range" min="50" max="250" id="x-pos" oninput="send();" value="140" /></p> |
|
|
|
|
</form> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|