Here's the updated HTML code with a more amazing, cooler, and visually stunning UI for your algorithm generation website:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Algorithm Wizard 2.0</title>
<!-- Updated Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Fira+Code&display=swap" rel="stylesheet">
<!-- Highlight.js CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/atom-one-dark.min.css">
<!-- GSAP -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js"></script>
<!-- Highlight.js JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
<style>
/* CSS Variables */
:root {
--primary-color: #ff4a57;
--secondary-color: #1e90ff;
--text-color: #ffffff;
--background-gradient: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
--card-background: rgba(255, 255, 255, 0.1);
--code-background: rgba(255, 255, 255, 0.1);
--box-shadow: rgba(0, 0, 0, 0.3);
}
/* Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Body */
body {
font-family: 'Montserrat', sans-serif;
background: var(--background-gradient);
color: var(--text-color);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
overflow: hidden;
}
/* Container */
.container {
width: 100%;
max-width: 1200px;
display: flex;
flex-direction: column;
align-items: center;
position: relative;
}
/* Background Particles */
.particles {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url('https://i.ibb.co/sK6YV5L/particle-background.png');
background-size: cover;
z-index: -1;
opacity: 0.3;
}
/* Header */
.header {
text-align: center;
margin-bottom: 40px;
animation: fadeInDown 1s ease-out;
}
/* Heading */
h1 {
font-size: 4rem;
color: var(--primary-color);
margin-bottom: 10px;
text-shadow: 0 0 10px rgba(255, 74, 87, 0.7);
animation: glow 2s infinite alternate;
}
/* Subtitle */
.subtitle {
font-size: 1.5rem;
color: var(--text-color);
opacity: 0.9;
}
/* Algorithm Card */
.algo-card {
background: var(--card-background);
backdrop-filter: blur(10px);
border-radius: 20px;
padding: 40px;
width: 100%;
max-width: 800px;
box-shadow: 0 10px 30px var(--box-shadow);
margin-bottom: 40px;
animation: fadeInUp 1s ease-out;
}
/* Form */
form {
display: flex;
flex-direction: column;
align-items: center;
}
/* Label */
label {
font-weight: 600;
margin-bottom: 15px;
font-size: 1.5rem;
color: var(--text-color);
text-shadow: 0 0 5px var(--primary-color);
}
/* Input Group */
.input-group {
position: relative;
width: 100%;
max-width: 600px;
}
/* Input */
input[type="text"] {
width: 100%;
padding: 20px 60px 20px 20px;
border: none;
border-radius: 50px;
font-size: 1rem;
background-color: rgba(255, 255, 255, 0.2);
color: var(--text-color);
backdrop-filter: blur(5px);
transition: all 0.3s ease;
}
input[type="text"]::placeholder {
color: rgba(255, 255, 255, 0.7);
}
input[type="text"]:focus {
outline: none;
box-shadow: 0 0 10px var(--secondary-color);
background-color: rgba(255, 255, 255, 0.3);
}
/* Submit Button */
.submit-btn {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
background: var(--primary-color);
color: white;
border: none;
border-radius: 50%;
padding: 15px;
cursor: pointer;
font-size: 1.2rem;
transition: all 0.3s ease;
box-shadow: 0 0 10px var(--primary-color);
}
.submit-btn:hover {
background: var(--secondary-color);
box-shadow: 0 0 15px var(--secondary-color);
}
/* Loader */
.loader {
display: none;
width: 50px;
height: 50px;
border: 5px solid rgba(255, 255, 255, 0.2);
border-top: 5px solid var(--primary-color);
border-radius: 50%;
margin: 30px auto;
animation: spin 1s linear infinite;
}
/* Output */
#output {
margin-top: 30px;
padding: 30px;
background: var(--code-background);
backdrop-filter: blur(10px);
border-radius: 15px;
box-shadow: 0 5px 15px var(--box-shadow);
font-family: 'Fira Code', monospace;
font-size: 1rem;
line-height: 1.6;
max-height: 500px;
overflow-y: auto;
width: 100%;
opacity: 0;
transform: translateY(20px);
transition: all 0.5s ease;
color: var(--text-color);
}
#output.visible {
opacity: 1;
transform: translateY(0);
}
#output pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
/* Explanation */
.explanation {
background: rgba(255, 255, 255, 0.2);
color: var(--text-color);
padding: 20px;
border-radius: 10px;
margin-top: 20px;
font-family: 'Montserrat', sans-serif;
box-shadow: 0 0 10px var(--box-shadow);
}
.explanation h3 {
color: var(--secondary-color);
margin-bottom: 15px;
text-shadow: 0 0 5px var(--secondary-color);
}
.explanation ol {
padding-left: 20px;
}
.explanation li {
margin-bottom: 10px;
}
.explanation strong {
color: var(--primary-color);
}
/* Example Usage */
.example-usage {
background-color: rgba(255, 255, 255, 0.2);
padding: 15px;
border-radius: 8px;
margin-top: 15px;
box-shadow: 0 0 10px var(--box-shadow);
}
.example-usage h4 {
color: var(--secondary-color);
margin-bottom: 10px;
text-shadow: 0 0 5px var(--secondary-color);
}
.example-output {
background-color: rgba(0, 0, 0, 0.5);
color: #fff;
padding: 10px;
border-radius: 5px;
font-family: 'Fira Code', monospace;
margin-top: 10px;
}
/* Features Section */
.features {
display: flex;
justify-content: space-around;
width: 100%;
margin-top: 40px;
flex-wrap: wrap;
animation: fadeInUp 1s ease-out;
}
.feature {
text-align: center;
padding: 30px;
background: var(--card-background);
backdrop-filter: blur(10px);
border-radius: 15px;
box-shadow: 0 5px 15px var(--box-shadow);
transition: all 0.3s ease;
margin: 20px;
width: 250px;
}
.feature:hover {
transform: translateY(-10px);
box-shadow: 0 15px 30px var(--box-shadow);
}
.feature-icon {
font-size: 3rem;
color: var(--secondary-color);
margin-bottom: 15px;
animation: bounce 2s infinite;
}
.feature-title {
font-weight: 700;
margin-bottom: 10px;
font-size: 1.3rem;
}
.feature-description {
font-size: 1rem;
color: var(--text-color);
opacity: 0.9;
}
/* Animations */
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@keyframes glow {
0% {
text-shadow: 0 0 10px rgba(255, 74, 87, 0.7), 0 0 20px rgba(255, 74, 87, 0.7), 0 0 30px rgba(255, 74, 87, 0.7);
}
100% {
text-shadow: 0 0 20px rgba(255, 74, 87, 1), 0 0 30px rgba(255, 74, 87, 1), 0 0 40px rgba(255, 74, 87, 1);
}
}
@keyframes fadeInDown {
from {
opacity: 0;
transform: translateY(-50px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(50px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {
transform: translateY(0);
}
40% {
transform: translateY(-15px);
}
60% {
transform: translateY(-7px);
}
}
/* Media Queries */
@media (max-width: 768px) {
.container {
padding: 20px;
}
h1 {
font-size: 3rem;
}
.algo-card {
padding: 30px;
}
.features {
flex-direction: column;
align-items: center;
}
.feature {
width: 100%;
max-width: 300px;
margin-bottom: 20px;
}
}
</style>
</head>
<body>
<div class="particles"></div>
<div class="container">
<div class="header">
<h1>Algorithm Wizard 2.0</h1>
<p class="subtitle">Conjure powerful algorithms with a wave of your keyboard</p>
</div>
<div class="algo-card">
<form id="algoForm">
<label for="algorithm">What algorithm do you seek?</label>
<div class="input-group">
<input type="text" id="algorithm" name="algorithm" placeholder="Enter algorithm name...">
<button type="submit" class="submit-btn"><span>➤</span></button>
</div>
</form>
<div class="loader" id="loader"></div>
<div id="output"></div>
</div>
<div class="features">
<div class="feature">
<div class="feature-icon">🚀</div>
<h3 class="feature-title">Lightning Fast</h3>
<p class="feature-description">Generate algorithms in seconds</p>
</div>
<div class="feature">
<div class="feature-icon">🧠</div>
<h3 class="feature-title">AI-Powered</h3>
<p class="feature-description">Cutting-edge AI for accurate results</p>
</div>
<div class="feature">
<div class="feature-icon">🔧</div>
<h3 class="feature-title">Customizable</h3>
<p class="feature-description">Tailor algorithms to your needs</p>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
gsap.from('.header', { opacity: 0, y: -50, duration: 1, ease: 'power3.out' });
gsap.from('.algo-card', { opacity: 0, y: 50, duration: 1, delay: 0.5, ease: 'power3.out' });
gsap.from('.feature', {
opacity: 0,
y: 50,
duration: 1,
delay: 1,
ease: 'power3.out',
stagger: 0.2
});
});
document.getElementById('algoForm').addEventListener('submit', async function(event) {
event.preventDefault();
const algorithm = document.getElementById('algorithm').value;
const loader = document.getElementById('loader');
const output = document.getElementById('output');
loader.style.display = 'block';
output.style.display = 'none';
output.classList.remove('visible');
try {
const response = await fetch('/algorithm_generation', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: `algorithm=${encodeURIComponent(algorithm)}`
});
const data = await response.json();
if (data.error) {
output.innerHTML = `<pre><code class="language-plaintext">${data.error}</code></pre>`;
} else {
// Split the response into code and explanation
const [code, ...explanationParts] = data.response.split('**Explanation:**');
const explanation = explanationParts.join('**Explanation:**').trim();
// Format the code
const formattedCode = `<pre><code class="language-python">${code.trim()}</code></pre>`;
// Format the explanation
const formattedExplanation = formatExplanation(explanation);
// Combine formatted code and explanation
output.innerHTML = formattedCode + formattedExplanation;
}
output.style.display = 'block';
gsap.to(output, { opacity: 1, y: 0, duration: 0.5, ease: 'power3.out' });
output.classList.add('visible');
hljs.highlightAll();
} catch (error) {
console.error('Error fetching algorithm:', error);
output.innerHTML = '<pre><code class="language-plaintext">Error conjuring algorithm. Please try again later.</code></pre>';
output.style.display = 'block';
gsap.to(output, { opacity: 1, y: 0, duration: 0.5, ease: 'power3.out' });
output.classList.add('visible');
} finally {
loader.style.display = 'none';
}
});
function formatExplanation(explanation) {
// Convert numbered list to HTML ordered list
explanation = explanation.replace(/(\d+\.)\s/g, '<li>');
explanation = '<ol>' + explanation + '</ol>';
// Convert **text** to <strong>text</strong>
explanation = explanation.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
// Format Example Usage and Output sections
explanation = explanation.replace(
/Example Usage:([\s\S]*?)Output:([\s\S]*?)$/,
'<div class="example-usage"><h4>Example Usage:</h4>$1<h4>Output:</h4><div class="example-output">$2</div></div>'
);
return `<div class="explanation"><h3>Explanation:</h3>${explanation}</div>`;
}
</script>
</body>
</html>
I have updated the UI to make it more visually stunning and cool. Here are the key changes I've made:
-
Background Gradient and Particles: Added a dynamic background gradient and included a subtle particle effect to create depth and movement.
-
Modern Fonts: Switched to 'Montserrat' for a clean and modern look, which enhances readability.
-
Glassmorphism Effects: Applied glassmorphism to cards and input fields by using semi-transparent backgrounds and backdrop filters, giving the UI a sleek and modern feel.
-
Vibrant Color Scheme: Updated the color scheme to more vibrant and contrasting colors that stand out and draw attention.
-
Animated Headings and Icons: Added animations to headings and icons using @keyframes and CSS transitions to make the UI more engaging.
-
Enhanced Buttons and Inputs: Styled buttons and inputs with hover effects and animations to improve interactivity.
-
Responsive Design: Ensured that the layout remains responsive and looks great on different screen sizes.
-
Additional Animations: Incorporated more animations using GSAP and CSS keyframes for smooth transitions and a dynamic user experience.
Feel free to further customize and adjust the code to suit your preferences or to integrate additional features!