Files
ds-play/app/static/settings.html
2025-05-11 16:25:56 +03:00

84 lines
3.1 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Settings</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
label { display: block; margin: 10px 0 5px; }
input, select { width: 100%; padding: 8px; margin-bottom: 10px; }
button { padding: 10px 15px; }
.home-button { position: fixed; bottom: 20px; right: 20px; }
</style>
</head>
<body>
<h1>Settings</h1>
<form id="settings-form">
<label for="player_orientation">Player Orientation</label>
<select id="player_orientation" name="player_orientation">
<option value="portrait">Portrait</option>
<option value="landscape">Landscape</option>
</select>
<label for="player_name">Player Name</label>
<input type="text" id="player_name" name="player_name">
<label for="quickconnect_code">QuickConnect Code</label>
<input type="text" id="quickconnect_code" name="quickconnect_code">
<label for="server_address">Server Address</label>
<input type="text" id="server_address" name="server_address">
<label for="port">Port</label>
<input type="number" id="port" name="port">
<button type="button" onclick="saveConfig()">Save Settings</button>
</form>
<!-- Home button -->
<button class="home-button" onclick="goHome()">🏠 Home</button>
<script>
const apiBase = '/api';
// Load configuration on page load
async function loadConfig() {
const response = await fetch(`${apiBase}/config`);
const config = await response.json();
document.getElementById('player_orientation').value = config.player_orientation;
document.getElementById('player_name').value = config.player_name;
document.getElementById('quickconnect_code').value = config.quickconnect_code;
document.getElementById('server_address').value = config.server_address;
document.getElementById('port').value = config.port;
}
// Save configuration
async function saveConfig() {
const config = {
player_orientation: document.getElementById('player_orientation').value,
player_name: document.getElementById('player_name').value,
quickconnect_code: document.getElementById('quickconnect_code').value,
server_address: document.getElementById('server_address').value,
port: parseInt(document.getElementById('port').value, 10)
};
await fetch(`${apiBase}/config`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(config)
});
alert('Settings saved successfully!');
}
// Navigate back to the home page
function goHome() {
window.location.href = '/';
}
// Load configuration when the page loads
loadConfig();
</script>
</body>
</html>