diff options
author | Devaev Maxim <[email protected]> | 2018-07-15 11:21:44 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-07-15 11:21:44 +0300 |
commit | 999d3f245710013425cc2413f81d900ec1fc2f24 (patch) | |
tree | 07bf519cab5da1b522e8146a362724762c8a3e7c /kvmd/web/js/hid.js | |
parent | 4122ecdb55abae00f2168d27df5f88527fc02341 (diff) |
big js refactoring
Diffstat (limited to 'kvmd/web/js/hid.js')
-rw-r--r-- | kvmd/web/js/hid.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/kvmd/web/js/hid.js b/kvmd/web/js/hid.js new file mode 100644 index 00000000..3d0ed961 --- /dev/null +++ b/kvmd/web/js/hid.js @@ -0,0 +1,29 @@ +var hid = new function() { + var __install_timer = null; + + this.installCapture = function(ws) { + var http = tools.makeRequest("GET", "/kvmd/hid", function() { + if (http.readyState === 4) { + if (http.status === 200) { + features = JSON.parse(http.responseText).result.features; + if (features.mouse) { + mouse.installCapture(ws); + } + keyboard.installCapture(ws); + } else { + tools.error("Can't resolve HID features:", http.responseText); + __install_timer = setTimeout(() => hid.installCapture(ws), 1000); + } + } + }); + }; + + this.clearCapture = function() { + if (__install_timer) { + clearTimeout(__install_timer); + __install_timer = null; + } + mouse.clearCapture(); + keyboard.clearCapture(); + }; +} |