|
7 | 7 | <title>Remote Titan</title> |
8 | 8 | <link rel="stylesheet" href="./main.css" /> |
9 | 9 | <link rel="stylesheet" href="./terminal.css" /> |
| 10 | + <style> |
| 11 | + .external { |
| 12 | + background-color: black; |
| 13 | + opacity: 0.3; |
| 14 | + display: table; |
| 15 | + position: absolute; |
| 16 | + top: 0; |
| 17 | + left: 0; |
| 18 | + height: 100%; |
| 19 | + width: 100%; |
| 20 | + } |
| 21 | + .middle { |
| 22 | + display: table-cell; |
| 23 | + vertical-align: middle; |
| 24 | + } |
| 25 | + .internal { |
| 26 | + opacity: 1; |
| 27 | + margin-left: auto; |
| 28 | + margin-right: auto; |
| 29 | + width: 400px; |
| 30 | + } |
| 31 | + </style> |
10 | 32 | <script defer> |
11 | | - const ws = new WebSocket(`ws://${new URL(window.location.href).host}/api/terminal`) |
| 33 | + const ws = new WebSocket( |
| 34 | + `ws://${new URL(window.location.href).host}/api/terminal` |
| 35 | + ); |
| 36 | + |
| 37 | + setTimeout(() => { |
| 38 | + if (ws.readyState === 1) { |
| 39 | + ws.send( |
| 40 | + JSON.stringify({ |
| 41 | + type: "test_payload", |
| 42 | + value: "none", |
| 43 | + }) |
| 44 | + ); |
| 45 | + } |
| 46 | + }, 5); |
| 47 | + |
| 48 | + ws.onmessage = function (data) { |
| 49 | + data = JSON.parse(data.data); |
| 50 | + |
| 51 | + if (data.value !== undefined) |
| 52 | + document.querySelector( |
| 53 | + "div.history" |
| 54 | + ).innerHTML += `<p>${data.value}</p>`; |
| 55 | + |
| 56 | + if (data.type === "validated") { |
| 57 | + document.querySelector("div.validate").innerHTML = ""; |
| 58 | + document.querySelector("div.root").style = ""; |
| 59 | + } |
| 60 | + }; |
| 61 | + |
| 62 | + function conn() { |
| 63 | + let inp = document.querySelector(".conn"); |
| 64 | + if (!inp.value) return; |
| 65 | + ws.send( |
| 66 | + JSON.stringify({ |
| 67 | + type: "verify", |
| 68 | + value: inp.value, |
| 69 | + }) |
| 70 | + ); |
| 71 | + } |
12 | 72 |
|
13 | 73 | function execute(event) { |
14 | 74 | const val = event.target.parentElement.children[0].children[4]; |
|
19 | 79 | if (val.value.includes("clear")) |
20 | 80 | event.target.parentElement.parentElement.children[2].children[0].textContent = |
21 | 81 | ""; |
22 | | - else { |
23 | 82 |
|
24 | | - } |
| 83 | + ws.send( |
| 84 | + JSON.stringify({ |
| 85 | + type: "cmd", |
| 86 | + value: val.value, |
| 87 | + }) |
| 88 | + ); |
25 | 89 |
|
26 | 90 | val.value = ""; |
27 | 91 | } |
28 | 92 | </script> |
29 | 93 | </head> |
30 | 94 | <body> |
31 | | - <div class="group"> |
32 | | - <div class="terminal_entry"> |
| 95 | + <div class="root" style="filter: blur(1px); pointer-events: none"> |
| 96 | + <div class="group"> |
| 97 | + <div class="terminal_entry"> |
| 98 | + <span> </span> |
| 99 | + <p class="user" style="color: #2ca32c">~</p> |
| 100 | + <p class="user"><span> </span>$</p> |
| 101 | + <span> </span> |
| 102 | + <input |
| 103 | + placeholder="Enter Terminal Command" |
| 104 | + class="entry" |
| 105 | + spellcheck="false" |
| 106 | + /> |
| 107 | + </div> |
33 | 108 | <span> </span> |
34 | | - <p class="user" style="color: #2ca32c">~</p> |
35 | | - <p class="user"><span> </span>$</p> |
36 | | - <span> </span> |
37 | | - <input |
38 | | - placeholder="Enter Terminal Command" |
39 | | - class="entry" |
40 | | - spellcheck="false" |
41 | | - /> |
| 109 | + <button class="execute" onclick="execute(event)">Run</button> |
| 110 | + </div> |
| 111 | + <br /> |
| 112 | + <div class="history"> |
| 113 | + <p class="time"></p> |
42 | 114 | </div> |
43 | | - <span> </span> |
44 | | - <button class="execute" onclick="execute(event)">Run</button> |
| 115 | + <script> |
| 116 | + document.querySelector( |
| 117 | + "p.time" |
| 118 | + ).textContent = `[${new Date().getHours()}:${ |
| 119 | + new Date().getMinutes() > 10 |
| 120 | + ? new Date().getMinutes() |
| 121 | + : `0${new Date().getMinutes()}` |
| 122 | + }:${ |
| 123 | + new Date().getSeconds() > 10 |
| 124 | + ? new Date().getSeconds() |
| 125 | + : `0${new Date().getSeconds()}` |
| 126 | + }] Remote Titan has been launched!`; |
| 127 | + </script> |
45 | 128 | </div> |
46 | | - <br /> |
47 | | - <div class="history"> |
48 | | - <p class="time"></p> |
| 129 | + <div class="validate"> |
| 130 | + <div class="external"> |
| 131 | + <div class="middle"> |
| 132 | + <div class="internal"> |
| 133 | + <input |
| 134 | + class="conn" |
| 135 | + placeholder="Enter Connection Code:" |
| 136 | + maxlength="6" |
| 137 | + /> |
| 138 | + <button onclick="conn()">Submit</button> |
| 139 | + </div> |
| 140 | + </div> |
| 141 | + </div> |
49 | 142 | </div> |
50 | | - <script> |
51 | | - document.querySelector( |
52 | | - "p.time" |
53 | | - ).textContent = `[${new Date().getHours()}:${ |
54 | | - new Date().getMinutes() > 10 |
55 | | - ? new Date().getMinutes() |
56 | | - : `0${new Date().getMinutes()}` |
57 | | - }:${ |
58 | | - new Date().getSeconds() > 10 |
59 | | - ? new Date().getSeconds() |
60 | | - : `0${new Date().getSeconds()}` |
61 | | - }] Remote Titan has been launched!`; |
62 | | - </script> |
63 | 143 | </body> |
64 | 144 | </html> |
0 commit comments