-
Notifications
You must be signed in to change notification settings - Fork 0
/
conv6.html
110 lines (101 loc) · 3.91 KB
/
conv6.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
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wii Error Codes Searcher</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f9f9f9;
color: #333;
}
input, button {
padding: 10px;
margin: 10px 0;
width: 100%;
box-sizing: border-box;
}
button {
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
#results {
margin-top: 20px;
background-color: white;
border: 1px solid #ccc;
padding: 10px;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>Wii Error Codes</h1>
<input type="text" id="searchInput" placeholder="Wii Error Code">
<button id="searchButton">Search</button>
<div id="results"></div>
<script>
async function fetchErrors() {
const response = await fetch('errors.json');
return await response.json();
}
function searchErrors(errors, query) {
const results = [];
const queryRegex = new RegExp(query.replace(/X/g, '\\d').replace(/y/g, '\\d'), 'i');
const numericQuery = parseInt(query, 10);
for (const code in errors) {
// Überprüfung auf "bis" Fehlercodes
const rangeMatch = code.match(/^(\d+)-(\d+)$/);
if (rangeMatch) {
const start = parseInt(rangeMatch[1]);
const end = parseInt(rangeMatch[2]);
if (numericQuery >= start && numericQuery <= end) {
results.push(`${code}: ${errors[code]}`);
}
} else {
// Suche nach genauen Übereinstimmungen oder Ersetzungen von X und y
if (queryRegex.test(code)) {
results.push(`${code}: ${errors[code]}`);
}
// Zusätzliche Suche für Fehlercodes mit X oder y
if (code.length === query.length && query.match(/[Xy]/)) {
const pattern = code.replace(/X/g, '[0-9]').replace(/y/g, '[0-9]');
const specialRegex = new RegExp(`^${pattern}$`, 'i');
if (specialRegex.test(query)) {
results.push(`${code}: ${errors[code]}`);
}
}
// Suche nach passenden Fehlercodes, die mit der Eingabe übereinstimmen
if (code.length === query.length + 1 && code.startsWith(query.slice(0, -1)) && (code.endsWith('X') || code.endsWith('y'))) {
results.push(`${code}: ${errors[code]}`);
}
}
}
return results;
}
document.getElementById('searchButton').addEventListener('click', async () => {
const query = document.getElementById('searchInput').value.trim();
if (!query) return;
const errors = await fetchErrors();
const results = searchErrors(errors, query);
const resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = '';
if (results.length === 0) {
resultsDiv.innerHTML = '<p>No Error Codes found. Try to remove the back characters until it works.</p>';
} else {
results.forEach(result => {
const div = document.createElement('div');
div.textContent = result;
resultsDiv.appendChild(div);
});
}
});
</script>
</body>
</html>