open-access-control-api/index.html

47 lines
1.6 KiB
HTML
Raw Normal View History

2019-07-07 03:59:45 +00:00
<html>
<head>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
2019-07-07 05:03:16 +00:00
// console.log("loaded socketio");
// connect to socketio
2019-07-07 03:59:45 +00:00
socket.on('connect', function(){
2019-07-07 05:03:16 +00:00
// send connect message
socket.send('hi '+window.location);
});
window.onload = function(){
cons = document.getElementById("console");
// handle user input
cons.onsubmit = function(){
inp = document.getElementById("input")
scr = document.getElementById("screen")
// send input to socketio
socket.emit('data',inp.value);
// console.log(inp.value);
scr.value += "> "+inp.value+"\r";
scr.scrollTop = scr.scrollHeight;
inp.value = "";
return false;
};
scr = document.getElementById("screen")
scr.value = ""; // reset input onload
// log data from socket
2019-07-07 03:59:45 +00:00
socket.on('data', function(data){
2019-07-07 05:03:16 +00:00
// console.log(data);
scr.value += "< "+data+"\r";
scr.scrollTop = scr.scrollHeight;
2019-07-07 03:59:45 +00:00
});
2019-07-07 05:03:16 +00:00
// log connect messages
socket.on('message', function(data){
console.log('message',window.location,data);
});
};
2019-07-07 03:59:45 +00:00
</script>
</head>
2019-07-07 05:03:16 +00:00
<form id="console">
<textarea cols=80 rows=20 id="screen"></textarea><br/>
<input id="input" type="text" />
<input id="submit" type="button" value="Submit" />
</form>
2019-07-07 03:59:45 +00:00
</html>