-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpanic_button.js
More file actions
64 lines (57 loc) · 2.5 KB
/
panic_button.js
File metadata and controls
64 lines (57 loc) · 2.5 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
54
55
56
57
58
59
60
61
62
63
64
var PanicButtonHandler = function() {
this.render = function(model_state) {
// Add panic button if it doesn't exist
if (!document.getElementById("panic-button")) {
console.log("Adding panic button");
var button = document.createElement("button");
button.id = "panic-button";
button.innerHTML = "TRIGGER PANIC!";
button.style.position = "fixed";
button.style.top = "60px";
button.style.right = "10px";
button.style.backgroundColor = "red";
button.style.color = "white";
button.style.padding = "10px";
button.style.fontWeight = "bold";
button.style.border = "none";
button.style.borderRadius = "5px";
button.style.cursor = "pointer";
button.style.zIndex = "1000";
button.onclick = function() {
console.log("Panic button clicked!");
// Send a custom message through the websocket
var message = {
"type": "panic_inject",
"method": "spatial"
};
ws.send(JSON.stringify(message));
};
document.body.appendChild(button);
// Add a second button for random panic
var randomButton = document.createElement("button");
randomButton.id = "random-panic-button";
randomButton.innerHTML = "RANDOM PANIC";
randomButton.style.position = "fixed";
randomButton.style.top = "110px";
randomButton.style.right = "10px";
randomButton.style.backgroundColor = "purple";
randomButton.style.color = "white";
randomButton.style.padding = "10px";
randomButton.style.fontWeight = "bold";
randomButton.style.border = "none";
randomButton.style.borderRadius = "5px";
randomButton.style.cursor = "pointer";
randomButton.style.zIndex = "1000";
randomButton.onclick = function() {
console.log("Random panic button clicked!");
// Send a custom message through the websocket
var message = {
"type": "panic_inject",
"method": "random"
};
ws.send(JSON.stringify(message));
};
document.body.appendChild(randomButton);
}
};
};