-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeeacheater.html
97 lines (83 loc) · 2.89 KB
/
beeacheater.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Letter Filter</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="wordList.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
box-sizing: border-box;
}
label, input, button {
display: block;
width: 100%;
margin-bottom: 15px;
}
label {
font-weight: bold;
}
input {
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 10px;
font-size: 16px;
background-color: #007BFF;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
#resultContainer {
margin-top: 20px;
}
@media (min-width: 600px) {
label, input, button {
width: 50%;
margin-left: auto;
margin-right: auto;
}
}
</style>
</head>
<body>
<label for="requiredLetter">Required letter:</label>
<input type="text" id="requiredLetter" maxlength="1" oninput="this.value = this.value.toLowerCase()" placeholder="e.g., a">
<label for="otherLetters">Other letters:</label>
<input type="text" id="otherLetters" maxlength="6" oninput="this.value = this.value.toLowerCase()" placeholder="e.g., bcdfgh">
<button onclick="filterWords()">Find Words</button>
<div id="resultContainer"></div>
<script>
function filterWords() {
const requiredLetter = document.getElementById('requiredLetter').value;
const otherLetters = document.getElementById('otherLetters').value;
if (!requiredLetter || requiredLetter.length !== 1) {
alert('Please enter one required letter.');
return;
}
const allowedLetters = requiredLetter + otherLetters;
const regex = new RegExp(`^[${allowedLetters}]+$`);
const filteredWords = wordList.filter(word =>
word.includes(requiredLetter) && regex.test(word) && word.length >= 4
);
const resultContainer = document.getElementById('resultContainer');
resultContainer.innerHTML = ''; // Clear previous results
filteredWords.forEach(word => {
const element = document.createElement('div');
element.textContent = word;
resultContainer.appendChild(element);
});
}
</script>
</body>
</html>