mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
better web
This commit is contained in:
parent
cd0ce2d6be
commit
52c94958f7
@ -7,22 +7,34 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<script src="js/kvmd.js"></script>
|
<script src="js/kvmd.js"></script>
|
||||||
<script> window.onload = runKvmdSession; </script>
|
<script>
|
||||||
|
window.onload = function() {
|
||||||
|
runKvmdSession();
|
||||||
|
pollStreamer();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="stream-box">
|
<div class="stream-box">
|
||||||
<img src="/streamer/?action=stream" id="stream-image" class="stream-image" alt="" />
|
<img src="/streamer/?action=stream" id="stream-image" class="stream-image" alt="" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table><tr>
|
<table>
|
||||||
<td><div id="power-led" class="power-led-off"></div></td>
|
<tr>
|
||||||
<td><div id="hdd-led" class="hdd-led-off"></div></td>
|
<td><div id="power-led" class="power-led-off"></div></td>
|
||||||
<td> </td>
|
<td><div id="hdd-led" class="hdd-led-off"></div></td>
|
||||||
<td><button id="power-button" type="button" title="Click hardware power button" onclick="clickPowerButton();">Power</button></td>
|
<td> </td>
|
||||||
<td><button id="power-button-long" type="button" title="Click hardware power button (long press)" onclick="clickPowerButtonLong();">Power (long)</button></td>
|
<td><button id="power-button" type="button" title="Click hardware power button" onclick="clickPowerButton();">Power</button></td>
|
||||||
<td><button id="reset-button" type="button" title="Click to force reset" onclick="clickResetButton();">Reset</button></td>
|
<td><button id="power-button-long" type="button" title="Click hardware power button (long press)" onclick="clickPowerButtonLong();">Power (long)</button></td>
|
||||||
<td> </td>
|
<td><button id="reset-button" type="button" title="Click to force reset" onclick="clickResetButton();">Reset</button></td>
|
||||||
<td><div id="session-status">Not connected yet...</div></td>
|
</tr>
|
||||||
</tr></table>
|
</table>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><button id="restart-stream-button" type="button" title="Click here if your video looks like a crap" onclick="resetStreamer();">Restart video</button></td>
|
||||||
|
<td> </td>
|
||||||
|
<td><div id="session-status">Not connected yet...</div></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -1,12 +1,7 @@
|
|||||||
KVMD_BASE_URL = "/kvmd"
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
function runKvmdSession() {
|
function runKvmdSession() {
|
||||||
var ws = new WebSocket("ws://" + location.host + KVMD_BASE_URL + "/ws");
|
var ws = new WebSocket("ws://" + location.host + "/kvmd/ws");
|
||||||
|
|
||||||
ws.onopen = function(event) {
|
ws.onopen = function(event) {
|
||||||
alert("Session opened and keyboard will be captured");
|
|
||||||
__installHidHandlers(ws);
|
__installHidHandlers(ws);
|
||||||
__setSessionStatus("session-opened", "Session opened (keyboard captured)");
|
__setSessionStatus("session-opened", "Session opened (keyboard captured)");
|
||||||
};
|
};
|
||||||
@ -86,14 +81,38 @@ function clickResetButton() {
|
|||||||
|
|
||||||
function __clickButton(button) {
|
function __clickButton(button) {
|
||||||
var http = new XMLHttpRequest();
|
var http = new XMLHttpRequest();
|
||||||
http.open("POST", KVMD_BASE_URL + "/atx/click?button=" + button, true);
|
http.open("POST", "/kvmd/atx/click?button=" + button, true);
|
||||||
http.onreadystatechange = function() {
|
http.onreadystatechange = function() {
|
||||||
if (http.readyState == 4) {
|
if (http.readyState == 4 && http.status != 200) {
|
||||||
if (http.status == 200) {
|
alert("Click error: " + http.responseText);
|
||||||
alert("Clicked!")
|
}
|
||||||
} else {
|
}
|
||||||
alert("Click error: " + http.responseText);
|
http.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
function pollStreamer() {
|
||||||
|
var http = new XMLHttpRequest();
|
||||||
|
http.open("GET", "/streamer/?action=snapshot", true);
|
||||||
|
http.onreadystatechange = function() {
|
||||||
|
if (http.readyState == 2) {
|
||||||
|
http.abort();
|
||||||
|
if (http.status != 200) {
|
||||||
|
document.getElementById("stream-image").src = "/streamer/?action=stream&time=" + new Date().getTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
http.send();
|
||||||
|
setTimeout(pollStreamer, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetStreamer() {
|
||||||
|
var http = new XMLHttpRequest();
|
||||||
|
http.open("POST", "/kvmd/streamer/reset", true);
|
||||||
|
http.onreadystatechange = function() {
|
||||||
|
if (http.readyState == 4 && http.status != 200) {
|
||||||
|
alert("Can't reset streamer: " + http.responseText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
http.send();
|
http.send();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user