-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
146 lines (115 loc) · 5.52 KB
/
index.html
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html>
<head>
<title>Configuration Editor</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1>Configuration Editor</h1>
<!-- Add a file input element for loading configuration files -->
<form id="config-form">
<label for="file-input" class="file-input-label">Choose a Configuration File:</label>
<input type="file" id="file-input" accept=".cfg, .ini" class="file-input-text">
<!-- Rest of the form fields -->
<label for="IpAddress">IP Address:</label>
<input type="text" id="IpAddress" name="IpAddress"><br>
<label for="GamePort">Game Port:</label>
<input type="number" id="GamePort" name="GamePort"><br>
<label for="QueryPort">Query Port:</label>
<input type="number" id="QueryPort" name="QueryPort"><br>
<label for="BlobSyncPort">Blob Sync Port:</label>
<input type="number" id="BlobSyncPort" name="BlobSyncPort"><br>
<label for="ServerName">Server Name:</label>
<input type="text" id="ServerName" name="ServerName"><br>
<label for="MaxPlayers">Max Players:</label>
<input type="number" id="MaxPlayers" name="MaxPlayers"><br>
<label for="Password">Password:</label>
<input type="text" id="Password" name="Password"><br>
<label for="LanOnly">LAN Only:</label>
<input type="checkbox" id="LanOnly" name="LanOnly"><br>
<label for="SaveSlot">Save Slot:</label>
<input type="number" id="SaveSlot" name="SaveSlot"><br>
<label for="SaveMode">Save Mode:</label>
<select id="SaveMode" name="SaveMode">
<option value="Continue" selected>Continue</option>
<option value="Manual">Manual</option>
</select><br>
<label for="GameMode">Game Mode:</label>
<select id="GameMode" name="GameMode">
<option value="normal" selected>Normal</option>
<option value="hard">Hard</option>
</select><br>
<label for="SaveInterval">Save Interval:</label>
<input type="number" id="SaveInterval" name="SaveInterval"><br>
<!-- More fields can be added here -->
<button type="submit">Save</button>
</form>
<script>
const form = document.getElementById('config-form');
// Event listener for the file input change
document.getElementById('file-input').addEventListener('change', (event) => {
const selectedFile = event.target.files[0];
if (selectedFile) {
loadConfig(selectedFile);
}
});
// Function to load the configuration file
function loadConfig(file) {
const reader = new FileReader();
reader.onload = function (event) {
const data = event.target.result;
try {
const configData = JSON.parse(data); // Assuming the config file is in JSON format
populateForm(configData);
} catch (parseError) {
console.error(parseError);
// Handle parsing error (e.g., invalid configuration file format)
}
};
reader.readAsText(file);
}
// Function to populate the form fields with loaded data
function populateForm(data) {
for (const key in data) {
const element = form.elements[key];
if (element) {
let value = data[key];
if (element.type === 'checkbox') {
element.checked = value;
} else {
// Set the value
element.value = value;
}
}
}
}
// Event listener for the form's submit event (handles saving)
form.addEventListener('submit', (event) => {
event.preventDefault(); // Prevent the default form submission
const formData = new FormData(form);
const updatedConfig = {};
// Convert FormData to a JSON object
formData.forEach((value, key) => {
updatedConfig[key] = value;
});
// Save the updated configuration data as a JSON file
saveConfig(updatedConfig);
});
// Function to save the updated configuration data as a JSON file
function saveConfig(data) {
const blob = new Blob([JSON.stringify(data, null, 4)], { type: 'application/json' });
const configFileName = 'config.cfg';
// Create a download link for the JSON file
const downloadLink = document.createElement('a');
downloadLink.href = URL.createObjectURL(blob);
downloadLink.download = configFileName;
// Trigger the download
downloadLink.click();
}
</script>
<!-- Footer Section -->
<footer class="text-center text-gray-500 py-4">
© 2023 SoF Configuration Editor by <a href="https://discord.com/channels/1017173116209868860/1187619349763199066/threads/1187619902459220060/1187619902459220060" target="_blank"><p class="text-center text-white py-4">NOLVUS</p></a> All rights reserved.
</footer>
</body>
</html>