-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArma3ModstingGeneratorWebApp.html
More file actions
143 lines (123 loc) · 5.02 KB
/
Arma3ModstingGeneratorWebApp.html
File metadata and controls
143 lines (123 loc) · 5.02 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arma 3 Mod ID Extractor</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
textarea {
width: 100%;
height: 150px;
margin-bottom: 10px;
}
.hidden {
display: none;
}
.signature {
margin-top: 20px;
font-style: italic;
text-align: center;
}
label {
cursor: pointer;
}
</style>
</head>
<body>
<h1>Arma 3 Mod ID Extractor</h1>
<label for="fileInput">Load .html File:</label>
<input type="file" id="fileInput" accept=".html">
<h3>Options:</h3>
<label><input type="checkbox" id="includeAt" onclick="updateOutput()"> Include '@' before each entry</label><br>
<label><input type="checkbox" id="showNames" checked onclick="updateOutput()"> Show Names (instead of only IDs)</label><br>
<h3>Output Format:</h3>
<label><input type="radio" name="format" value="newline" checked onclick="updateOutput()"> Newline</label><br>
<label><input type="radio" name="format" value="semicolon" onclick="updateOutput()"> Semicolon</label><br>
<label><input type="radio" name="format" value="comma" onclick="updateOutput()"> Comma</label><br>
<h3>Extracted Output:</h3>
<textarea id="output" readonly>Output will appear here...</textarea>
<h3>Sanitized Mods:</h3>
<textarea id="sanitizedMods" readonly>No mods required sanitization.</textarea>
<button onclick="downloadOutput()">Save List</button>
<div class="signature">Developed by Waldo</div>
<script>
let extractedData = [];
let sanitizedMods = [];
let isDataLoaded = false;
document.getElementById('fileInput').addEventListener('change', function(event) {
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
processFile(e.target.result);
isDataLoaded = true;
updateOutput(); // Update the output box immediately after loading
};
reader.readAsText(file);
}
});
function sanitizeFilename(name) {
const invalidChars = /[<>:"/\\|?*]/g;
const unescapedName = name.replace(/&/g, '&');
return unescapedName.replace(invalidChars, '-');
}
function processFile(content) {
extractedData = [];
sanitizedMods = [];
const lines = content.split('\n');
let displayName = '';
lines.forEach(line => {
if (line.includes('data-type="DisplayName"')) {
displayName = line.split('>')[1].split('<')[0];
}
if (line.includes('?id=')) {
const id = line.match(/\?id=(\d+)/)[1];
const sanitizedName = sanitizeFilename(displayName);
if (sanitizedName !== displayName && !displayName.includes('&')) {
sanitizedMods.push(`Original: ${displayName}\nSanitized: ${sanitizedName}`);
}
extractedData.push({ name: sanitizedName, id });
}
});
updateSanitizedMods();
}
function updateOutput() {
if (!isDataLoaded) {
document.getElementById('output').value = "Output will appear here...";
return;
}
const includeAt = document.getElementById('includeAt').checked;
const showNames = document.getElementById('showNames').checked;
const format = document.querySelector('input[name="format"]:checked').value;
let output = extractedData.map(entry => {
let value = showNames ? entry.name : entry.id;
return includeAt ? `@${value}` : value;
});
if (format === 'semicolon') {
output = output.join(';');
} else if (format === 'comma') {
output = output.join(',');
} else {
output = output.join('\n');
}
document.getElementById('output').value = output;
}
function updateSanitizedMods() {
const sanitizedModsText = sanitizedMods.length ? sanitizedMods.join('\n\n') : "No mods required sanitization.";
document.getElementById('sanitizedMods').value = sanitizedModsText;
}
function downloadOutput() {
const output = document.getElementById('output').value;
const blob = new Blob([output], { type: 'text/plain' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'mod_list.txt';
link.click();
}
</script>
</body>
</html>