mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-12-12 06:14:09 +01:00
chat: wip rework as chat2
This commit is contained in:
31
resources/[gameplay]/chat/html/utils.ts
Normal file
31
resources/[gameplay]/chat/html/utils.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
export function post(url: string, data: any) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('POST', url, true);
|
||||
request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
|
||||
request.send(data);
|
||||
}
|
||||
|
||||
function emulate(type: string, detail = {}) {
|
||||
const detailRef = {
|
||||
type,
|
||||
...detail
|
||||
};
|
||||
|
||||
window.dispatchEvent(new CustomEvent('message', {
|
||||
detail: detailRef
|
||||
}));
|
||||
}
|
||||
|
||||
(window as any)['emulate'] = emulate;
|
||||
|
||||
(window as any)['demo'] = () => {
|
||||
emulate('ON_MESSAGE', {
|
||||
message: {
|
||||
args: [ 'me', 'hello!' ]
|
||||
}
|
||||
})
|
||||
|
||||
emulate('ON_SCREEN_STATE_CHANGE', {
|
||||
shouldHide: false
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user