-
Notifications
You must be signed in to change notification settings - Fork 0
/
converter.html
70 lines (63 loc) · 2.29 KB
/
converter.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
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Error Code Lookup</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
padding: 0;
}
input[type="text"] {
width: 300px;
padding: 10px;
margin-bottom: 10px;
}
button {
padding: 10px 15px;
}
.result {
margin-top: 20px;
padding: 10px;
border: 1px solid #ccc;
background-color: #f9f9f9;
}
</style>
</head>
<body>
<h1>Error Code Lookup</h1>
<input type="text" id="errorCode" placeholder="Wii Error Code">
<button onclick="lookupErrorCode()">Search</button>
<div class="result" id="result"></div>
<script>
async function lookupErrorCode() {
const code = document.getElementById('errorCode').value.trim();
const resultDiv = document.getElementById('result');
// Laden der errors.json
const response = await fetch('errors.json');
const errors = await response.json();
// Ersetzen von Platzhaltern durch reguläre Ausdrücke
const regexPattern = code
.replace(/X/g, '\\d*') // X durch beliebige Ziffern ersetzen
.replace(/Y/g, '\\d*') // Y durch beliebige Ziffern ersetzen
.replace(/x/g, '\\d*') // x durch beliebige Ziffern ersetzen
.replace(/y/g, '\\d*') // y durch beliebige Ziffern ersetzen
.replace(/(\d+)/g, '($1)'); // Ziffern in Gruppen setzen
const regex = new RegExp(`^${regexPattern}$`);
// Suche nach passenden Fehlercodes
const matches = Object.entries(errors).filter(([key, value]) => regex.test(key));
// Anzeige der Ergebnisse
if (matches.length > 0) {
resultDiv.innerHTML = '<h3>Error-Codes:</h3>';
matches.forEach(([key, value]) => {
resultDiv.innerHTML += `<p>${key}: ${value}</p>`;
});
} else {
resultDiv.innerHTML = '<p>No Error Codes found</p>';
}
}
</script>
</body>
</html>