|
|
<!DOCTYPE html> |
|
|
<html lang="en"> |
|
|
<head> |
|
|
<meta charset="UTF-8"> |
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
|
<title>Minecraft Admin Console</title> |
|
|
<style> |
|
|
body { |
|
|
background-color: #1e1e1e; |
|
|
color: #d4d4d4; |
|
|
font-family: 'Consolas', 'Monaco', monospace; |
|
|
margin: 0; |
|
|
padding: 20px; |
|
|
display: flex; |
|
|
flex-direction: column; |
|
|
height: 100vh; |
|
|
box-sizing: border-box; |
|
|
} |
|
|
#login-container { |
|
|
margin: auto; |
|
|
text-align: center; |
|
|
padding: 20px; |
|
|
border: 1px solid #333; |
|
|
background-color: #252526; |
|
|
} |
|
|
#console-container { |
|
|
display: none; |
|
|
flex-direction: column; |
|
|
height: 100%; |
|
|
width: 100%; |
|
|
} |
|
|
#output { |
|
|
flex-grow: 1; |
|
|
border: 1px solid #333; |
|
|
background-color: #000; |
|
|
padding: 10px; |
|
|
overflow-y: scroll; |
|
|
white-space: pre-wrap; |
|
|
word-wrap: break-word; |
|
|
font-size: 14px; |
|
|
} |
|
|
#command-input { |
|
|
width: 100%; |
|
|
padding: 10px; |
|
|
margin-top: 10px; |
|
|
border: 1px solid #333; |
|
|
background-color: #252526; |
|
|
color: #d4d4d4; |
|
|
font-family: inherit; |
|
|
font-size: 16px; |
|
|
box-sizing: border-box; |
|
|
} |
|
|
input { |
|
|
font-size: 16px; padding: 8px; |
|
|
} |
|
|
button { |
|
|
font-size: 16px; padding: 8px 12px; cursor: pointer; |
|
|
} |
|
|
</style> |
|
|
</head> |
|
|
<body> |
|
|
|
|
|
<div id="login-container"> |
|
|
<h2>Enter Admin Password</h2> |
|
|
<input type="password" id="password-input" placeholder="Password"> |
|
|
<button onclick="login()">Login</button> |
|
|
<p id="error-message" style="color: red;"></p> |
|
|
</div> |
|
|
|
|
|
<div id="console-container"> |
|
|
<h1>Minecraft Server Console</h1> |
|
|
<div id="output">Connecting to server...</div> |
|
|
<input type="text" id="command-input" placeholder="Enter command (e.g., list, op username) and press Enter"> |
|
|
</div> |
|
|
|
|
|
<script> |
|
|
const passwordInput = document.getElementById('password-input'); |
|
|
const loginContainer = document.getElementById('login-container'); |
|
|
const consoleContainer = document.getElementById('console-container'); |
|
|
const output = document.getElementById('output'); |
|
|
const commandInput = document.getElementById('command-input'); |
|
|
const errorMessage = document.getElementById('error-message'); |
|
|
|
|
|
const CORRECT_PASSWORD = "4219"; |
|
|
let ws; |
|
|
|
|
|
function login() { |
|
|
if (passwordInput.value === CORRECT_PASSWORD) { |
|
|
loginContainer.style.display = 'none'; |
|
|
consoleContainer.style.display = 'flex'; |
|
|
connectWebSocket(); |
|
|
} else { |
|
|
errorMessage.textContent = 'Incorrect password.'; |
|
|
} |
|
|
} |
|
|
|
|
|
passwordInput.addEventListener('keydown', (event) => { |
|
|
if (event.key === 'Enter') { |
|
|
login(); |
|
|
} |
|
|
}); |
|
|
|
|
|
function connectWebSocket() { |
|
|
|
|
|
|
|
|
|
|
|
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const wsUrl = `${wsProtocol}//${window.location.hostname}:8765`; |
|
|
|
|
|
|
|
|
const hfWsUrl = `${wsProtocol}//${window.location.host}/-/8765/`; |
|
|
|
|
|
|
|
|
ws = new WebSocket(hfWsUrl); |
|
|
|
|
|
ws.onopen = () => { |
|
|
output.innerHTML = 'Connected to server console.<br>'; |
|
|
}; |
|
|
|
|
|
ws.onmessage = (event) => { |
|
|
const message = document.createElement('div'); |
|
|
message.textContent = event.data; |
|
|
output.appendChild(message); |
|
|
|
|
|
output.scrollTop = output.scrollHeight; |
|
|
}; |
|
|
|
|
|
ws.onclose = () => { |
|
|
const message = document.createElement('div'); |
|
|
message.style.color = 'red'; |
|
|
message.textContent = 'Disconnected from server. Attempting to reconnect in 5 seconds...'; |
|
|
output.appendChild(message); |
|
|
output.scrollTop = output.scrollHeight; |
|
|
setTimeout(connectWebSocket, 5000); |
|
|
}; |
|
|
|
|
|
ws.onerror = (error) => { |
|
|
console.error('WebSocket Error:', error); |
|
|
const message = document.createElement('div'); |
|
|
message.style.color = 'orange'; |
|
|
message.textContent = 'WebSocket connection error.'; |
|
|
output.appendChild(message); |
|
|
output.scrollTop = output.scrollHeight; |
|
|
}; |
|
|
} |
|
|
|
|
|
commandInput.addEventListener('keydown', (event) => { |
|
|
if (event.key === 'Enter' && commandInput.value.trim() !== '') { |
|
|
if (ws && ws.readyState === WebSocket.OPEN) { |
|
|
ws.send(commandInput.value); |
|
|
commandInput.value = ''; |
|
|
} else { |
|
|
alert('Not connected to the server.'); |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
</script> |
|
|
</body> |
|
|
</html> |