You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/rdp.html

111 lines
3.0 KiB

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<style>
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
display: flex;
align-items: center;
/* justify-content: center; */
}
#display {
height: 100vh;
width: 100vw;
}
</style>
</head>
<body>
<!-- Guacamole -->
<script type="text/javascript" src="/js/rdp.all.min.js"></script>
<!-- Display -->
<div id="display"></div>
<!-- Init -->
<script type="text/javascript"> /* <![CDATA[ */
var pattern = /(\w+)=([^\#&]*)/ig;
var parames = {};
location.href.replace(pattern, function (attr, key, value) {
parames[key] = decodeURI(value);
});
// Get display div from document
var display = document.getElementById("display");
let urls = `wss://webssh.educoder.net/${parames.gpPort ? 'kube' : 'tunnel'}`;
if (window.location.hostname.split('.')?.[0]?.indexOf("test") > -1 || window.location.hostname.split('.')?.[0]?.indexOf("pre") > -1 || window.top.location.href.indexOf("localhost") > -1) {
urls = `wss://pre-webssh.educoder.net/${parames.gpPort ? 'kube' : 'tunnel'}`;
}
// Instantiate client, using an HTTP tunnel for communications.
var guac = new Guacamole.Client(
//new Guacamole.HTTPTunnel("tunnel")
//new Guacamole.HTTPTunnel("http://192.168.2.90:8081/tunnel")
new Guacamole.WebSocketTunnel(urls)
);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror = function (error) {
console.log(JSON.stringify(error))
};
// Connect
guac.connect(`${parames.gpPort ? ('gpPort=' + parames.gpPort + '&' + 'password=' + parames.password + '&') : ''}` + "tpiID=" + parames.tpiId + "&envId=" + parames.envId + "&tpiType=" + parames.tpiType + "&width=1920&height=1080");
// Disconnect on close
window.onunload = function () {
guac.disconnect();
}
// console.log("guac:",guac)
// setTimeout(() => {
// console.log("guac:",guac)
//
// },4000)
display.addEventListener('click', () => {
display.tabIndex = 0;
display.focus();
})
// Mouse
var mouse = new Guacamole.Mouse(guac.getDisplay().getElement());
mouse.onmousedown =
mouse.onmouseup =
mouse.onmousemove = function (mouseState) {
guac.sendMouseState(mouseState);
};
// Keyboard
var keyboard = new Guacamole.Keyboard(document);
keyboard.onkeydown = function (keysym) {
guac.sendKeyEvent(1, keysym);
};
keyboard.onkeyup = function (keysym) {
guac.sendKeyEvent(0, keysym);
};
/* ]]> */</script>
</body>
</html>