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