This repository was archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAFKOverlay.ts
More file actions
53 lines (47 loc) · 1.91 KB
/
Copy pathAFKOverlay.ts
File metadata and controls
53 lines (47 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright Epic Games, Inc. All Rights Reserved.
import { ActionOverlay } from './ActionOverlay';
/**
* Show an overlay for when the session is unattended, it begins a countdown timer, which when elapsed will disconnect the stream.
*/
export class AFKOverlay extends ActionOverlay {
/**
* @returns The created root element of this overlay.
*/
public static createRootElement(): HTMLElement {
const afkOverlayHtml = document.createElement('div');
afkOverlayHtml.id = 'afkOverlay';
afkOverlayHtml.className = 'clickableState';
return afkOverlayHtml;
}
/**
* @returns The created content element of this overlay, which contain some text for an afk count down.
*/
public static createContentElement(): HTMLElement {
const afkOverlayHtmlInner = document.createElement('div');
afkOverlayHtmlInner.id = 'afkOverlayInner';
afkOverlayHtmlInner.innerHTML =
'<center>No activity detected<br>Disconnecting in <span id="afkCountDownNumber"></span> seconds<br>Click to continue<br></center>';
return afkOverlayHtmlInner;
}
/**
* Construct an Afk overlay
* @param parentElement the element this overlay will be inserted into
*/
public constructor(rootDiv: HTMLElement) {
super(
rootDiv,
AFKOverlay.createRootElement(),
AFKOverlay.createContentElement()
);
this.rootElement.addEventListener('click', () => {
this.activate();
});
}
/**
* Update the count down spans number for the overlay
* @param countdown the count down number to be inserted into the span for updating
*/
public updateCountdown(countdown: number): void {
this.textElement.innerHTML = `<center>No activity detected<br>Disconnecting in <span id="afkCountDownNumber">${countdown}</span> seconds<br>Click to continue<br></center>`;
}
}