-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.html
More file actions
69 lines (58 loc) · 2.55 KB
/
generator.html
File metadata and controls
69 lines (58 loc) · 2.55 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
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Universal Wrapper Player</title>
<link rel="icon" href="./favicon.ico" type="image/x-icon">
<script src="./js/config.js"></script>
</head>
<body>
<h1>Universal Wrapper Player</h1>
<form id="playerForm">
<label for="environment">Environment:</label>
<select id="environment" name="environment" required></select><br><br>
<div id="dynamicFields"></div>
<button type="submit">Submit</button>
</form>
<script>
const environmentSelect = document.getElementById('environment');
const dynamicFields = document.getElementById('dynamicFields');
for (const key in environment) {
const option = document.createElement('option');
option.value = key;
option.textContent = key.charAt(0).toUpperCase() + key.slice(1);
environmentSelect.appendChild(option);
}
environmentSelect.addEventListener('change', function() {
const selectedEnvironment = environment[this.value];
dynamicFields.innerHTML = '';
for (const section in selectedEnvironment) {
for (const field in selectedEnvironment[section]) {
const value = selectedEnvironment[section][field];
const label = document.createElement('label');
label.textContent = `${field}:`;
const input = document.createElement('input');
input.type = 'text';
input.name = field;
input.value = typeof value === 'object' ? JSON.stringify(value) : value;
dynamicFields.appendChild(label);
dynamicFields.appendChild(input);
dynamicFields.appendChild(document.createElement('br'));
}
}
});
document.getElementById('playerForm').addEventListener('submit', function(event) {
event.preventDefault();
const formData = new FormData(this);
const params = new URLSearchParams();
for (const [key, value] of formData.entries()) {
params.append(key, value);
}
window.location.href = `index.html?${params.toString()}`;
});
// Trigger change event to populate fields for the default selected environment
environmentSelect.dispatchEvent(new Event('change'));
</script>
</body>
</html>