website / index.html
dolijagan's picture
there are 5 errors but shows no errors waste ai unable to understand - Initial Deployment
4124eb1 verified
Raw History Blame Contribute Delete
27 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Powered Debugger | Smart Code Analysis</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<style>
.code-editor {
min-height: 300px;
font-family: 'Fira Code', monospace;
tab-size: 4;
line-height: 1.5;
}
.error-highlight {
background-color: rgba(239, 68, 68, 0.3);
border-left: 3px solid #ef4444;
position: relative;
}
.warning-highlight {
background-color: rgba(234, 179, 8, 0.3);
border-left: 3px solid #eab308;
position: relative;
}
.suggestion-highlight {
background-color: rgba(34, 197, 94, 0.3);
border-left: 3px solid #22c55e;
position: relative;
}
.result-container {
max-height: 400px;
overflow-y: auto;
}
.language-badge {
position: absolute;
top: 1rem;
right: 1rem;
background: rgba(255,255,255,0.2);
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-size: 0.875rem;
font-weight: 500;
}
.code-line-highlight {
background-color: rgba(59, 130, 246, 0.2);
}
.highlight-tooltip {
position: absolute;
bottom: 100%;
left: 0;
background: #1f2937;
color: white;
padding: 0.5rem;
border-radius: 0.375rem;
font-size: 0.875rem;
z-index: 10;
display: none;
}
.error-highlight:hover .highlight-tooltip {
display: block;
}
</style>
</head>
<body class="bg-gray-50">
<!-- Hero Section -->
<div class="relative bg-gradient-to-r from-blue-600 to-indigo-800 text-white py-20">
<div class="container mx-auto px-6 text-center">
<h1 class="text-4xl md:text-6xl font-bold mb-6" data-aos="fade-down">AI Powered Debugger</h1>
<p class="text-xl md:text-2xl mb-8 max-w-3xl mx-auto" data-aos="fade-down" data-aos-delay="100">
Smart code analysis that detects errors and suggests improvements instantly
</p>
<div class="flex flex-col md:flex-row justify-center gap-4" data-aos="fade-up" data-aos-delay="200">
<button id="tryNowBtn" class="bg-white text-blue-600 hover:bg-gray-100 px-8 py-3 rounded-lg font-semibold text-lg shadow-lg transform transition hover:scale-105">
Try Now
</button>
<button class="border-2 border-white hover:bg-white hover:text-blue-600 px-8 py-3 rounded-lg font-semibold text-lg shadow-lg transform transition hover:scale-105">
How It Works
</button>
</div>
</div>
</div>
<!-- Main Debugger Section -->
<div class="container mx-auto px-6 py-16">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
<!-- Code Input Section -->
<div class="bg-white rounded-xl shadow-xl overflow-hidden" data-aos="fade-right">
<div class="bg-gray-800 text-white px-6 py-4 flex justify-between items-center">
<h2 class="text-xl font-semibold">Your Code</h2>
<div class="flex space-x-4">
<button id="pasteBtn" class="flex items-center gap-2 bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-lg text-sm">
<i data-feather="clipboard"></i> Paste
</button>
<button id="uploadBtn" class="flex items-center gap-2 bg-gray-700 hover:bg-gray-600 px-4 py-2 rounded-lg text-sm">
<i data-feather="upload"></i> Upload
</button>
<input type="file" id="fileInput" class="hidden" accept=".js,.py,.java,.c,.cpp,.php,.html,.css">
</div>
</div>
<div class="relative">
<div id="languageBadge" class="language-badge hidden text-white"></div>
<textarea id="codeInput" class="w-full p-4 code-editor bg-gray-900 text-gray-100 font-mono text-sm"
placeholder="Paste your code here or upload a file..."
spellcheck="false"></textarea>
</div>
<div class="bg-gray-100 px-6 py-4 flex justify-end">
<button id="analyzeBtn" class="bg-green-600 hover:bg-green-700 text-white px-8 py-3 rounded-lg font-semibold shadow-lg transform transition hover:scale-105 flex items-center gap-2">
<i data-feather="search"></i> Analyze Code
</button>
</div>
</div>
<!-- Results Section -->
<div class="bg-white rounded-xl shadow-xl overflow-hidden" data-aos="fade-left">
<div class="bg-gray-800 text-white px-6 py-4">
<h2 class="text-xl font-semibold">Analysis Results</h2>
</div>
<div id="resultsContainer" class="result-container p-4">
<div class="text-center py-16 text-gray-400">
<i data-feather="code" class="w-12 h-12 mx-auto mb-4"></i>
<p>Your analysis results will appear here</p>
</div>
</div>
<div class="bg-gray-100 px-6 py-4 flex justify-between items-center">
<div id="statsContainer" class="text-sm text-gray-600">
<span id="errorCount" class="hidden">0 errors</span>
<span id="warningCount" class="hidden ml-4">0 warnings</span>
<span id="suggestionCount" class="hidden ml-4">0 suggestions</span>
</div>
<button id="copyResultsBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm hidden">
<i data-feather="copy"></i> Copy Results
</button>
</div>
</div>
</div>
</div>
<!-- Features Section -->
<div class="bg-gray-100 py-16">
<div class="container mx-auto px-6">
<h2 class="text-3xl font-bold text-center mb-12" data-aos="fade-up">Powerful Debugging Features</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
<div class="bg-white p-8 rounded-xl shadow-lg" data-aos="fade-up" data-aos-delay="100">
<div class="text-blue-600 mb-4">
<i data-feather="search" class="w-8 h-8"></i>
</div>
<h3 class="text-xl font-semibold mb-3">Error Detection</h3>
<p class="text-gray-600">Identifies syntax errors, logical flaws, and potential bugs in your code with precision.</p>
</div>
<div class="bg-white p-8 rounded-xl shadow-lg" data-aos="fade-up" data-aos-delay="200">
<div class="text-green-600 mb-4">
<i data-feather="lightbulb" class="w-8 h-8"></i>
</div>
<h3 class="text-xl font-semibold mb-3">Smart Suggestions</h3>
<p class="text-gray-600">Provides intelligent recommendations to improve code quality and performance.</p>
</div>
<div class="bg-white p-8 rounded-xl shadow-lg" data-aos="fade-up" data-aos-delay="300">
<div class="text-purple-600 mb-4">
<i data-feather="zap" class="w-8 h-8"></i>
</div>
<h3 class="text-xl font-semibold mb-3">Fast Analysis</h3>
<p class="text-gray-600">Processes your code instantly with our powerful AI engine, saving you time.</p>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer class="bg-gray-800 text-white py-12">
<div class="container mx-auto px-6">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-6 md:mb-0">
<h2 class="text-2xl font-bold">AI Powered Debugger</h2>
<p class="text-gray-400 mt-2">Making debugging effortless since 2023</p>
</div>
<div class="flex space-x-6">
<a href="#" class="hover:text-blue-400 transition">Privacy</a>
<a href="#" class="hover:text-blue-400 transition">Terms</a>
<a href="#" class="hover:text-blue-400 transition">Contact</a>
</div>
</div>
<div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-400">
<p>© 2023 AI Powered Debugger. All rights reserved.</p>
</div>
</div>
</footer>
<script>
AOS.init();
feather.replace();
// Sample functionality
document.getElementById('tryNowBtn').addEventListener('click', () => {
document.getElementById('codeInput').scrollIntoView({ behavior: 'smooth' });
});
document.getElementById('pasteBtn').addEventListener('click', async () => {
try {
const text = await navigator.clipboard.readText();
document.getElementById('codeInput').value = text;
} catch (err) {
alert('Failed to read clipboard. Please paste manually.');
}
});
document.getElementById('uploadBtn').addEventListener('click', () => {
document.getElementById('fileInput').click();
});
document.getElementById('fileInput').addEventListener('change', (e) => {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = (event) => {
document.getElementById('codeInput').value = event.target.result;
};
reader.readAsText(file);
}
});
document.getElementById('analyzeBtn').addEventListener('click', () => {
const code = codeInput.value;
if (!code.trim()) {
alert('Please enter or upload some code to analyze');
return;
}
analyzeCode(code);
});
// Auto-detect and analyze when pasting significant code
codeInput.addEventListener('paste', (e) => {
setTimeout(() => {
const code = codeInput.value;
if (code.length > 100) { // Only auto-analyze if substantial code was pasted
detectLanguage();
analyzeCode(code);
}
}, 100);
});
function detectLanguage(code) {
const languageBadge = document.getElementById('languageBadge');
languageBadge.classList.remove('hidden');
// Simple language detection based on code patterns
if (code.includes('<?php') || code.includes('<?=')) {
languageBadge.textContent = 'PHP';
return 'php';
} else if (code.includes('def ') || code.includes('import ')) {
languageBadge.textContent = 'Python';
return 'python';
} else if (code.includes('function ') || code.includes('=>') || code.includes('const ') || code.includes('let ')) {
languageBadge.textContent = 'JavaScript';
return 'javascript';
} else if (code.includes('#include') || code.includes('int main(')) {
languageBadge.textContent = 'C/C++';
return 'cpp';
} else if (code.includes('public class') || code.includes('System.out.')) {
languageBadge.textContent = 'Java';
return 'java';
} else if (code.includes('<html') || code.includes('<div')) {
languageBadge.textContent = 'HTML';
return 'html';
} else if (code.includes('{') && code.includes('}') && code.includes(':')) {
languageBadge.textContent = 'CSS';
return 'css';
} else {
languageBadge.textContent = 'Unknown';
return 'unknown';
}
}
async function analyzeCode(code) {
// Show loading state
const resultsContainer = document.getElementById('resultsContainer');
resultsContainer.innerHTML = `
<div class="text-center py-16">
<div class="inline-block animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-blue-600 mb-4"></div>
<p>Analyzing your code with AI...</p>
</div>
`;
try {
// Detect language first
const language = detectLanguage(code);
// More robust analysis with better error detection
const analysisResults = await performDeepAnalysis(code, language);
displayResults(analysisResults);
// Highlight error lines in the code
const errorLines = analysisResults.filter(r => r.type === 'error').map(r => r.line);
const warningLines = analysisResults.filter(r => r.type === 'warning').map(r => r.line);
const suggestionLines = analysisResults.filter(r => r.type === 'suggestion').map(r => r.line);
if (errorLines.length > 0) highlightErrorLines(errorLines, 'error');
if (warningLines.length > 0) highlightErrorLines(warningLines, 'warning');
if (suggestionLines.length > 0) highlightErrorLines(suggestionLines, 'suggestion');
} catch (error) {
console.error('Analysis error:', error);
resultsContainer.innerHTML = `
<div class="bg-red-50 border-l-4 border-red-500 p-4">
<div class="flex">
<div class="flex-shrink-0 text-red-500">
<i data-feather="alert-circle" class="w-5 h-5"></i>
</div>
<div class="ml-3">
<p class="text-sm text-red-700 font-medium">Analysis failed</p>
<div class="mt-2 text-sm text-red-600">
<p>${error.message || 'Unknown error occurred during analysis'}</p>
<p class="mt-1">Please try again or check your code for obvious errors.</p>
</div>
</div>
</div>
</div>
`;
feather.replace();
// Reset stats
document.getElementById('statsContainer').innerHTML = '';
document.getElementById('copyResultsBtn').classList.add('hidden');
}
}
async function performDeepAnalysis(code, language) {
return new Promise((resolve) => {
// Simulate API call delay
setTimeout(() => {
const lines = code.split('\n');
const results = [];
// More accurate error detection
lines.forEach((line, index) => {
const lineNumber = index + 1;
const trimmedLine = line.trim();
// Common error patterns
if (language === 'javascript') {
if (trimmedLine.includes('=') && !trimmedLine.includes('let') &&
!trimmedLine.includes('const') && !trimmedLine.includes('var')) {
results.push(createErrorResult(
lineNumber,
'Undeclared variable assignment',
`Add declaration (let/const/var) before assignment`,
line
));
}
if (trimmedLine.includes('function(') || trimmedLine.includes('function (')) {
results.push(createWarningResult(
lineNumber,
'Consider using arrow function',
`Replace with: const myFunc = () => {...}`,
line
));
}
}
// Syntax error detection
if (trimmedLine.includes('{') && !trimmedLine.includes('}') ||
trimmedLine.includes('(') && !trimmedLine.includes(')') ||
trimmedLine.includes('[') && !trimmedLine.includes(']')) {
results.push(createErrorResult(
lineNumber,
'Possible unclosed bracket/parenthesis',
`Check for matching closing character`,
line
));
}
// Empty catch blocks
if (trimmedLine.includes('catch') && trimmedLine.includes('{') &&
lines[index+1] && lines[index+1].trim() === '}') {
results.push(createWarningResult(
lineNumber,
'Empty catch block',
`Add error handling logic in catch block`,
line
));
}
});
// If no issues found
if (results.length === 0) {
results.push({
type: 'success',
message: 'No issues found in your code!',
suggestion: 'Great job! Your code looks clean.'
});
}
resolve(results);
}, 1000);
});
}
function createErrorResult(line, message, suggestion, codeLine) {
return {
type: 'error',
line: line,
message: message,
suggestion: `${suggestion}\n\nError location: "${codeLine.trim()}"`,
code: codeLine
};
}
function createWarningResult(line, message, suggestion, codeLine) {
return {
type: 'warning',
line: line,
message: message,
suggestion: `${suggestion}\n\nWarning location: "${codeLine.trim()}"`,
code: codeLine
};
}
function highlightErrorLines(lines, type) {
const codeInput = document.getElementById('codeInput');
const code = codeInput.value.split('\n');
let highlightedCode = '';
code.forEach((line, index) => {
const lineNumber = index + 1;
if (lines.includes(lineNumber)) {
highlightedCode += `<span class="${type}-highlight">${escapeHtml(line)}</span>\n`;
} else {
highlightedCode += `${escapeHtml(line)}\n`;
}
});
// Create a temporary div to hold the highlighted code
const tempDiv = document.createElement('div');
tempDiv.innerHTML = highlightedCode;
// Replace the textarea with the highlighted version
const codeContainer = document.createElement('div');
codeContainer.className = 'code-editor bg-gray-900 text-gray-100 font-mono text-sm p-4 whitespace-pre';
codeContainer.innerHTML = highlightedCode;
codeInput.parentNode.replaceChild(codeContainer, codeInput);
// Add tooltips to highlighted lines
document.querySelectorAll(`.${type}-highlight`).forEach(highlight => {
const tooltip = document.createElement('div');
tooltip.className = 'highlight-tooltip';
tooltip.textContent = `${type.charAt(0).toUpperCase() + type.slice(1)} detected`;
highlight.appendChild(tooltip);
});
}
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
function displayResults(results) {
const resultsContainer = document.getElementById('resultsContainer');
const errorCount = results.filter(r => r.type === 'error').length;
const warningCount = results.filter(r => r.type === 'warning').length;
const suggestionCount = results.filter(r => r.type === 'suggestion').length;
let html = '';
if (results.some(r => r.type === 'success')) {
html = `
<div class="bg-green-50 border-l-4 border-green-500 p-4 mb-4">
<div class="flex">
<div class="flex-shrink-0 text-green-500">
<i data-feather="check-circle" class="w-5 h-5"></i>
</div>
<div class="ml-3">
<p class="text-sm text-green-700">${results[0].message}</p>
</div>
</div>
</div>
`;
} else {
results.forEach(result => {
const colorClass = result.type === 'error' ? 'red' :
result.type === 'warning' ? 'yellow' : 'green';
html += `
<div class="bg-${colorClass}-50 border-l-4 border-${colorClass}-500 p-4 mb-4">
<div class="flex">
<div class="flex-shrink-0 text-${colorClass}-500">
<i data-feather="${result.type === 'error' ? 'x-circle' :
result.type === 'warning' ? 'alert-triangle' : 'info'}"
class="w-5 h-5"></i>
</div>
<div class="ml-3">
<p class="text-sm text-${colorClass}-700 font-medium">
${result.type.toUpperCase()}${result.line ? ` on line ${result.line}` : ''}: ${result.message}
</p>
${result.suggestion ? `
<div class="mt-2 text-sm text-${colorClass}-600">
<p class="font-semibold">Suggestion:</p>
<div class="bg-white p-3 rounded mt-2 font-mono text-sm">
${result.suggestion.replace(/\n/g, '<br>')}
</div>
${result.code ? `
<div class="mt-2">
<p class="font-semibold">Problematic code:</p>
<div class="bg-gray-800 text-gray-100 p-2 rounded mt-1 font-mono text-sm">
${escapeHtml(result.code)}
</div>
</div>
` : ''}
</div>
` : ''}
</div>
</div>
</div>
`;
});
}
resultsContainer.innerHTML = html;
feather.replace();
// Update stats
const statsContainer = document.getElementById('statsContainer');
const copyBtn = document.getElementById('copyResultsBtn');
if (errorCount + warningCount + suggestionCount > 0) {
statsContainer.innerHTML = `
<span class="text-red-600">${errorCount} errors</span>
<span class="text-yellow-600 ml-4">${warningCount} warnings</span>
<span class="text-green-600 ml-4">${suggestionCount} suggestions</span>
`;
copyBtn.classList.remove('hidden');
} else {
statsContainer.innerHTML = '';
copyBtn.classList.add('hidden');
}
}
document.getElementById('copyResultsBtn').addEventListener('click', () => {
const resultsText = document.getElementById('resultsContainer').innerText;
navigator.clipboard.writeText(resultsText).then(() => {
const originalText = document.getElementById('copyResultsBtn').innerHTML;
document.getElementById('copyResultsBtn').innerHTML = '<i data-feather="check"></i> Copied!';
feather.replace();
setTimeout(() => {
document.getElementById('copyResultsBtn').innerHTML = originalText;
feather.replace();
}, 2000);
});
});
</script>
</body>
</html>