Certainly! Below, I will provide a simple HTML, CSS, and JS implementation that generates patterns based on your description. It will allow the user to enter custom characters and generate patterns, along with the descriptions of how many "things" are in each pattern.
Here's a basic structure for this application:
HTML (index.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pattern Permutator</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Pattern Permutator</h1>
<div>
<label for="customInput1">Custom Character 1:</label>
<input type="text" id="customInput1" maxlength="5" placeholder="Enter character"/>
<label for="customInput2">Custom Character 2:</label>
<input type="text" id="customInput2" maxlength="5" placeholder="Enter character"/>
<label for="customInput3">Custom Character 3:</label>
<input type="text" id="customInput3" maxlength="5" placeholder="Enter character"/>
<label for="customInput4">Custom Character 4:</label>
<input type="text" id="customInput4" maxlength="5" placeholder="Enter character"/>
<label for="customInput5">Custom Character 5:</label>
<input type="text" id="customInput5" maxlength="5" placeholder="Enter character"/>
</div>
<button id="generateButton">Generate Patterns</button>
<div id="output" class="output"></div>
</div>
<script src="script.js"></script>
</body>
</html>
CSS (styles.css)
body {
font-family: Arial, sans-serif;
background: #f4f4f4;
padding: 20px;
}
.container {
max-width: 600px;
margin: auto;
padding: 20px;
background: white;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
}
label {
display: block;
margin: 10px 0 5px;
}
input {
width: 100%;
padding: 10px;
margin-bottom: 10px;
}
button {
padding: 10px 15px;
background: #007BFF;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background: #0056b3;
}
.output {
margin-top: 20px;
white-space: pre-wrap; /* to preserve spacing */
}
JavaScript (script.js)
document.getElementById('generateButton').addEventListener('click', function () {
const customInputs = [
document.getElementById('customInput1').value,
document.getElementById('customInput2').value,
document.getElementById('customInput3').value,
document.getElementById('customInput4').value,
document.getElementById('customInput5').value,
].filter(input => input !== '');
const outputDiv = document.getElementById('output');
outputDiv.innerHTML = ''; // Clear previous output
if (customInputs.length === 0) {
outputDiv.innerHTML = 'Please enter at least one custom character.';
return;
}
const patterns = [];
for (let i = 1; i <= customInputs.length; i++) {
let pattern = '|_' + '_|'.repeat(i - 1);
patterns.push(`This is ${i} thing(s): ${pattern}`);
}
// Pattern with custom characters
customInputs.forEach(char => {
for (let j = 1; j <= customInputs.length; j++) {
let customPattern = char + '_|'.repeat(j - 1);
patterns.push(`This is ${j} thing(s) with character "${char}": ${customPattern}`);
}
});
// Output the patterns
outputDiv.innerHTML = patterns.join('\n');
});
Explanation:
- The HTML creates a form where you can input up to 5 custom characters.
- The CSS styles the layout to make it visually appealing.
- The JavaScript handles the input, generates the patterns based on how many "things" you want, and displays them in the output div.
Usage:
- Save each section into their respective files (
index.html, styles.css, script.js).
- Open the HTML file in a web browser.
- Enter your custom characters and click "Generate Patterns" to see the output patterns.