mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 09:18:53 +00:00
2e892cd946
Initial commit
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
var documentWidth = document.documentElement.clientWidth;
|
|
var documentHeight = document.documentElement.clientHeight;
|
|
|
|
var cursor = document.getElementById("cursor");
|
|
var cursorX = documentWidth / 2;
|
|
var cursorY = documentHeight / 2;
|
|
|
|
function UpdateCursorPos() {
|
|
cursor.style.left = cursorX;
|
|
cursor.style.top = cursorY;
|
|
}
|
|
|
|
function Click(x, y) {
|
|
var element = $(document.elementFromPoint(x, y));
|
|
element.focus().click();
|
|
}
|
|
|
|
$(function() {
|
|
window.addEventListener('message', function(event) {
|
|
if (event.data.type == "enableui") {
|
|
cursor.style.display = event.data.enable ? "block" : "none";
|
|
document.body.style.display = event.data.enable ? "block" : "none";
|
|
} else if (event.data.type == "click") {
|
|
// Avoid clicking the cursor itself, click 1px to the top/left;
|
|
Click(cursorX - 1, cursorY - 1);
|
|
}
|
|
});
|
|
|
|
$(document).mousemove(function(event) {
|
|
cursorX = event.pageX;
|
|
cursorY = event.pageY;
|
|
UpdateCursorPos();
|
|
});
|
|
|
|
document.onkeyup = function (data) {
|
|
if (data.which == 27) { // Escape key
|
|
$.post('http://esx_identity/escape', JSON.stringify({}));
|
|
}
|
|
};
|
|
|
|
$("#register").submit(function(e) {
|
|
e.preventDefault(); // Prevent form from submitting
|
|
|
|
$.post('http://esx_identity/register', JSON.stringify({
|
|
firstname: $("#firstname").val(),
|
|
lastname: $("#lastname").val(),
|
|
dateofbirth: $("#dateofbirth").val(),
|
|
sex: $("#sex").val(),
|
|
height: $("#height").val()
|
|
}));
|
|
});
|
|
});
|