add slider js

master
zenls 6 years ago
parent dcf2c676ce
commit 0919138ef0
  1. 60
      www/index.html

@ -14,6 +14,64 @@
<!-- JS -->
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">
var sock = null;
var ellog = null;
window.onload = function() {
ellog = document.getElementById('log');
var wsuri;
if (window.location.protocol === "file:") {
wsuri = "ws://10.174.136.143:45684/ws?a=23&foo=bar";
} else {
wsuri = "ws://" + window.location.hostname + ":45684/ws?a=23&foo=bar";
}
if ("WebSocket" in window) {
sock = new WebSocket(wsuri);
} else if ("MozWebSocket" in window) {
sock = new MozWebSocket(wsuri);
} else {
log("Browser does not support WebSocket!");
}
if (sock) {
sock.onopen = function() {
log("Connected to " + wsuri);
}
sock.onclose = function(e) {
log("Connection closed (wasClean = " + e.wasClean + ", code = " + e.code + ", reason = '" + e.reason + "')");
sock = null;
}
sock.onmessage = function(e) {
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);
} else {
log("Not connected.");
}
};
function log(m) {
ellog.innerHTML += m + '\n';
ellog.scrollTop = ellog.scrollHeight;
};
</script>
</head>
<body>
@ -58,7 +116,7 @@
<br>
<br>
<form class="range-field">
<input type="range" value="20" min="0" max="100" oninput="alert('Клик!')" />
<input type="range" min="50" max="250" id="size" oninput="send();" value="140" />
</form>
</div>

Loading…
Cancel
Save