HID: change POST to socketio
This commit is contained in:
parent
19086199c0
commit
009d008b5b
@ -6,6 +6,7 @@
|
||||
<style>
|
||||
</style>
|
||||
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js" integrity="sha256-yr4fRk/GU1ehYJPAs8P4JlTgu0Hdsp4ZKrx8bDEDC3I=" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body>
|
||||
HID input keyboard, POST data to /keyboard<br/>
|
||||
@ -16,6 +17,9 @@
|
||||
Server response: <span></span>
|
||||
|
||||
<script>
|
||||
var socket = io();
|
||||
|
||||
|
||||
function zapis(t) {
|
||||
$("div").text(t);
|
||||
}
|
||||
@ -36,25 +40,17 @@ $(window).bind('keydown', function(event) {
|
||||
shiftKey: event.shiftKey,
|
||||
altKey: event.altKey,
|
||||
which: event.which,
|
||||
code: event.code,
|
||||
code: event.code,
|
||||
str: str
|
||||
}
|
||||
|
||||
if (event.which != 16 && event.which != 17 && event.which != 18) {
|
||||
console.log(obj);
|
||||
|
||||
var ret = $.ajax({
|
||||
type: "POST",
|
||||
url: "hid/keyboard",
|
||||
data: JSON.stringify(obj),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json"
|
||||
});
|
||||
|
||||
$("span").text(ret.responseText);
|
||||
console.log(ret);
|
||||
|
||||
socket.emit('kbdEvent', JSON.stringify(obj));
|
||||
|
||||
$("span").text(ret.responseText);
|
||||
console.log(ret);
|
||||
}
|
||||
|
||||
var text = "";
|
||||
|
@ -11,7 +11,9 @@
|
||||
function zapis(t) {
|
||||
$("div").text(t);
|
||||
}
|
||||
|
||||
|
||||
var socket = io();
|
||||
|
||||
var previous;
|
||||
|
||||
$(window).bind('keydown', function(event) {
|
||||
@ -34,16 +36,9 @@
|
||||
|
||||
if (event.which != 16 && event.which != 17 && event.which != 18) {
|
||||
console.log(obj);
|
||||
socket.emit('kbdEvent', JSON.stringify(obj));
|
||||
|
||||
var ret = $.ajax({
|
||||
type: "POST",
|
||||
url: "hid/keyboard",
|
||||
data: JSON.stringify(obj),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json"
|
||||
});
|
||||
|
||||
console.log(ret);
|
||||
console.log(ret);
|
||||
}
|
||||
|
||||
var text = "";
|
||||
@ -59,7 +54,7 @@
|
||||
text = text + ' + ' + str;
|
||||
text = text.substr(3);
|
||||
zapis(text);
|
||||
|
||||
|
||||
previous = event.keyCode;
|
||||
|
||||
});
|
||||
@ -67,9 +62,7 @@
|
||||
var posX=0;
|
||||
var posY=0;
|
||||
var wheel=0;
|
||||
|
||||
var socket = io();
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$("img").mousedown(function(event){
|
||||
|
Loading…
Reference in New Issue
Block a user