Files
ds-play/app/static/settings.html
2025-05-11 19:36:32 +03:00

123 lines
4.3 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;
background-color: black; /* Set background to black */
color: white; /* Set text color to white */
}
label {
display: block;
margin: 10px 0 5px;
}
input, select {
width: 100%;
padding: 8px;
margin-bottom: 10px;
background-color: #333; /* Dark background for inputs */
color: white; /* White text for inputs */
border: 1px solid #555; /* Subtle border for inputs */
border-radius: 4px; /* Rounded corners */
}
button {
padding: 10px 15px;
background-color: #444; /* Dark button background */
color: white; /* White text for buttons */
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #666; /* Lighter background on hover */
}
.home-button {
position: fixed;
bottom: 20px;
right: 20px;
background-color: #444; /* Dark background for home button */
color: white;
border: none;
border-radius: 5px;
padding: 10px 15px;
cursor: pointer;
}
.home-button:hover {
background-color: #666; /* Lighter background on hover */
}
</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>