<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="AI Programming Assistant by Tomi - Generate code HTML, CSS, JavaScript, Python gratis">
<meta name="keywords" content="AI, programming, code generator, HTML, CSS, JavaScript, Python, Tomi">
<meta name="author" content="Tomi">
<meta name="robots" content="index, follow">
<!-- Open Graph -->
<meta property="og:title" content="AI Programming Assistant - Tomi">
<meta property="og:description" content="Generate code dengan AI gratis">
<meta property="og:url" content="https://ai-progamming-asisten-tomi.full.diskon.cloud/">
<meta property="og:type" content="website">
<!-- Favicon -->
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🤖</text></svg>">
<title>AI Programming Assistant | Tomi</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
mono: ['JetBrains Mono', 'monospace'],
},
colors: {
primary: '#3b82f6',
secondary: '#8b5cf6',
dark: '#0f172a',
}
}
}
}
</script>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Inter', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.glass {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.code-block {
background: #1e293b;
color: #e2e8f0;
font-family: 'JetBrains Mono', monospace;
}
.syntax-keyword { color: #c084fc; }
.syntax-string { color: #86efac; }
.syntax-function { color: #60a5fa; }
.syntax-comment { color: #64748b; }
.syntax-number { color: #fbbf24; }
.btn-glow:hover {
box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}
.fade-in {
animation: fadeIn 0.3s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.loading-spinner {
border: 3px solid rgba(255,255,255,0.3);
border-radius: 50%;
border-top-color: #3b82f6;
width: 24px;
height: 24px;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
background: #cbd5e1;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #94a3b8;
}
</style>
</head>
<body class="antialiased">
<!-- Header -->
<header class="fixed top-0 w-full z-50 glass shadow-lg">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between items-center h-16">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-gradient-to-br from-blue-500 to-purple-600 rounded-lg flex items-center justify-center text-white text-xl">
🤖
</div>
<div>
<h1 class="text-xl font-bold text-gray-900">AI Programming</h1>
<p class="text-xs text-gray-500">by Tomi</p>
</div>
</div>
<div class="flex items-center gap-4">
<a href="https://github.com" target="_blank" class="text-gray-600 hover:text-gray-900 transition">
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>
</a>
<div class="hidden sm:flex items-center gap-2 px-3 py-1 bg-green-100 rounded-full">
<span class="w-2 h-2 bg-green-500 rounded-full animate-pulse"></span>
<span class="text-xs text-green-700 font-medium">Online</span>
</div>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="pt-24 pb-12 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto">
<!-- Hero Section -->
<div class="text-center mb-10">
<h2 class="text-4xl sm:text-5xl font-bold text-white mb-4">
Generate Code dengan <span class="text-yellow-300">AI</span>
</h2>
<p class="text-xl text-white/90 max-w-2xl mx-auto">
Buat aplikasi web, game, dan script Python dalam hitungan detik. Gratis & tanpa registrasi!
</p>
</div>
<!-- Input Section -->
<div class="glass rounded-2xl p-6 mb-8 shadow-xl">
<div class="mb-4">
<label class="block text-sm font-semibold text-gray-700 mb-2 uppercase tracking-wide">
Apa yang ingin Anda buat?
</label>
<textarea
id="userInput"
class="w-full p-4 border-2 border-gray-200 rounded-xl focus:border-blue-500 focus:outline-none resize-none text-gray-700"
rows="3"
placeholder="Contoh: Buatkan kalkulator BMI dengan desain modern, responsif, dan animasi smooth..."
></textarea>
</div>
<div class="flex flex-wrap gap-2 mb-4">
<button onclick="setQuickPrompt('kalkulator')" class="px-4 py-2 bg-blue-50 text-blue-600 rounded-lg text-sm font-medium hover:bg-blue-100 transition">🧮 Kalkulator</button>
<button onclick="setQuickPrompt('todo')" class="px-4 py-2 bg-green-50 text-green-600 rounded-lg text-sm font-medium hover:bg-green-100 transition">✅ To-Do App</button>
<button onclick="setQuickPrompt('game')" class="px-4 py-2 bg-purple-50 text-purple-600 rounded-lg text-sm font-medium hover:bg-purple-100 transition">🎮 Game Snake</button>
<button onclick="setQuickPrompt('portfolio')" class="px-4 py-2 bg-orange-50 text-orange-600 rounded-lg text-sm font-medium hover:bg-orange-100 transition">💼 Portfolio</button>
<button onclick="setQuickPrompt('python')" class="px-4 py-2 bg-yellow-50 text-yellow-600 rounded-lg text-sm font-medium hover:bg-yellow-100 transition">🐍 Python Script</button>
</div>
<div class="flex gap-3">
<button onclick="generateCode()" id="generateBtn" class="flex-1 bg-gradient-to-r from-blue-600 to-purple-600 text-white py-3 px-6 rounded-xl font-semibold hover:opacity-90 transition btn-glow flex items-center justify-center gap-2">
<span>⚡ Generate Code</span>
</button>
<button onclick="clearAll()" class="px-6 py-3 border-2 border-gray-300 text-gray-600 rounded-xl font-semibold hover:bg-gray-50 transition">
Reset
</button>
</div>
</div>
<!-- Output Section -->
<div id="outputSection" class="hidden grid grid-cols-1 lg:grid-cols-2 gap-6">
<!-- Code Editor -->
<div class="glass rounded-2xl overflow-hidden shadow-xl flex flex-col" style="min-height: 500px;">
<div class="flex items-center justify-between px-4 py-3 bg-gray-50 border-b">
<div class="flex items-center gap-2">
<div class="flex gap-1.5">
<div class="w-3 h-3 rounded-full bg-red-400"></div>
<div class="w-3 h-3 rounded-full bg-yellow-400"></div>
<div class="w-3 h-3 rounded-full bg-green-400"></div>
</div>
<span class="ml-3 font-mono text-sm text-gray-600" id="filename">index.html</span>
</div>
<div class="flex gap-2">
<button onclick="copyCode()" class="p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition" title="Copy code">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path></svg>
</button>
<button onclick="downloadCode()" class="p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition" title="Download file">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path></svg>
</button>
</div>
</div>
<pre id="codeDisplay" class="code-block flex-1 p-4 overflow-auto text-sm leading-relaxed"><code>// Kode akan muncul di sini...</code></pre>
</div>
<!-- Preview -->
<div class="glass rounded-2xl overflow-hidden shadow-xl flex flex-col" style="min-height: 500px;">
<div class="flex items-center justify-between px-4 py-3 bg-gray-50 border-b">
<span class="font-semibold text-gray-600 flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path></svg>
Live Preview
</span>
<button onclick="refreshPreview()" class="text-sm text-gray-500 hover:text-gray-700 flex items-center gap-1 transition">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path></svg>
Refresh
</button>
</div>
<div class="flex-1 bg-white relative">
<iframe id="previewFrame" class="w-full h-full border-none"></iframe>
</div>
</div>
</div>
<!-- Features -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mt-12">
<div class="glass rounded-xl p-6 text-center hover:scale-105 transition duration-300">
<div class="text-4xl mb-4">⚡</div>
<h3 class="font-bold text-gray-800 mb-2">Cepat & Gratis</h3>
<p class="text-gray-600 text-sm">Generate code dalam hitungan detik tanpa biaya</p>
</div>
<div class="glass rounded-xl p-6 text-center hover:scale-105 transition duration-300">
<div class="text-4xl mb-4">🎨</div>
<h3 class="font-bold text-gray-800 mb-2">Desain Modern</h3>
<p class="text-gray-600 text-sm">UI/UX yang responsif dan profesional</p>
</div>
<div class="glass rounded-xl p-6 text-center hover:scale-105 transition duration-300">
<div class="text-4xl mb-4">💾</div>
<h3 class="font-bold text-gray-800 mb-2">Siap Pakai</h3>
<p class="text-gray-600 text-sm">Download dan deploy langsung ke hosting</p>
</div>
</div>
</main>
<!-- Footer -->
<footer class="glass mt-12 py-8">
<div class="max-w-7xl mx-auto px-4 text-center">
<p class="text-gray-600">
© 2024 AI Programming Assistant by <span class="font-semibold text-blue-600">Tomi</span>
</p>
<p class="text-sm text-gray-500 mt-2">
Hosted on <a href="https://diskon.cloud" class="text-blue-500 hover:underline">diskon.cloud</a>
</p>
</div>
</footer>
<!-- Toast Notification -->
<div id="toast" class="fixed bottom-4 left-1/2 transform -translate-x-1/2 bg-gray-800 text-white px-6 py-3 rounded-lg shadow-lg hidden fade-in z-50">
<span id="toastMessage">Notification</span>
</div>
<script>
// Quick Prompts
function setQuickPrompt(type) {
const prompts = {
kalkulator: 'Buatkan kalkulator BMI dengan desain modern, gradient background, animasi smooth, dan responsive. Tampilkan kategori berat badan dengan warna yang berbeda.',
todo: 'Buatkan aplikasi to-do list dengan fitur tambah task, checklist selesai, hapus task, dan local storage. Desain clean dengan animasi.',
game: 'Buatkan game snake klasik yang bisa dimainkan dengan keyboard arrow keys. Ada score, high score, dan game over screen.',
portfolio: 'Buatkan website portfolio profesional dengan hero section, skills, projects, dan contact. Desain modern dengan animasi scroll.',
python: 'Buatkan script Python untuk analisis data dengan class structure, type hints, dan error handling. Include sample data generator.'
};
document.getElementById('userInput').value = prompts[type];
}
// Main Generate Function
function generateCode() {
const input = document.getElementById('userInput').value.trim();
if (!input) {
showToast('Silakan masukkan deskripsi aplikasi!');
return;
}
const btn = document.getElementById('generateBtn');
const originalContent = btn.innerHTML;
btn.innerHTML = '<div class="loading-spinner"></div><span>Generating...</span>';
btn.disabled = true;
setTimeout(() => {
const lowerInput = input.toLowerCase();
let code = '';
let filename = 'index.html';
if (lowerInput.includes('python')) {
code = generatePython(input);
filename = 'script.py';
} else if (lowerInput.includes('kalkulator') || lowerInput.includes('bmi') || lowerInput.includes('calculator')) {
code = generateCalculator();
filename = 'index.html';
} else if (lowerInput.includes('todo') || lowerInput.includes('task')) {
code = generateTodo();
filename = 'index.html';
} else if (lowerInput.includes('game') || lowerInput.includes('snake')) {
code = generateGame();
filename = 'game.html';
} else if (lowerInput.includes('portfolio') || lowerInput.includes('website')) {
code = generatePortfolio();
filename = 'index.html';
} else {
code = generateDefault(input);
filename = 'index.html';
}
displayCode(code, filename);
updatePreview(code);
document.getElementById('outputSection').classList.remove('hidden');
btn.innerHTML = originalContent;
btn.disabled = false;
showToast('Code berhasil digenerate!');
// Scroll to output
document.getElementById('outputSection').scrollIntoView({ behavior: 'smooth', block: 'start' });
}, 1500);
}
// Code Generators
function generateCalculator() {
return `<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kalkulator BMI</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Segoe UI', system-ui, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
background: white;
padding: 40px;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
max-width: 400px;
width: 100%;
animation: slideUp 0.5s ease;
}
@keyframes slideUp {
from { opacity: 0; transform: translateY(30px); }
to { opacity: 1; transform: translateY(0); }
}
h1 { text-align: center; color: #333; margin-bottom: 8px; }
.subtitle { text-align: center; color: #666; margin-bottom: 30px; font-size: 14px; }
.input-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 6px; color: #555; font-weight: 500; font-size: 14px; }
input {
width: 100%;
padding: 12px 16px;
border: 2px solid #e0e0e0;
border-radius: 10px;
font-size: 16px;
transition: all 0.3s;
}
input:focus { outline: none; border-color: #667eea; }
button {
width: 100%;
padding: 14px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 10px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
}
button:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4); }
#result {
margin-top: 24px;
padding: 20px;
border-radius: 12px;
text-align: center;
display: none;
animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.bmi-value { font-size: 48px; font-weight: bold; color: #333; }
.bmi-status { font-size: 18px; margin-top: 8px; font-weight: 500; }
.underweight { background: #dbeafe; color: #1e40af; }
.normal { background: #dcfce7; color: #166534; }
.overweight { background: #fed7aa; color: #9a3412; }
.obese { background: #fecaca; color: #991b1b; }
</style>
</head>
<body>
<div class="container">
<h1>🏥 Kalkulator BMI</h1>
<p class="subtitle">Hitung indeks massa tubuh Anda</p>
<div class="input-group">
<label for="height">Tinggi Badan (cm)</label>
<input type="number" id="height" placeholder="Contoh: 170" step="0.1">
</div>
<div class="input-group">
<label for="weight">Berat Badan (kg)</label>
<input type="number" id="weight" placeholder="Contoh: 65" step="0.1">
</div>
<button onclick="calculateBMI()">Hitung BMI</button>
<div id="result">
<div class="bmi-value" id="bmiValue">0</div>
<div class="bmi-status" id="bmiStatus">-</div>
</div>
</div>
<script>
function calculateBMI() {
const height = parseFloat(document.getElementById('height').value);
const weight = parseFloat(document.getElementById('weight').value);
if (!height || !weight || height <= 0 || weight <= 0) {
alert('Mohon masukkan tinggi dan berat badan yang valid!');
return;
}
const bmi = weight / Math.pow(height / 100, 2);
const bmiFixed = bmi.toFixed(1);
let status = '';
let className = '';
if (bmi < 18.5) {
status = 'Kekurangan Berat Badan 🥗';
className = 'underweight';
} else if (bmi < 24.9) {
status = 'Berat Badan Normal ✅';
className = 'normal';
} else if (bmi < 29.9) {
status = 'Kelebihan Berat Badan ⚠️';
className = 'overweight';
} else {
status = 'Obesitas 🚨';
className = 'obese';
}
const resultDiv = document.getElementById('result');
document.getElementById('bmiValue').textContent = bmiFixed;
document.getElementById('bmiStatus').textContent = status;
resultDiv.className = className;
resultDiv.style.display = 'block';
}
document.addEventListener('keypress', function(e) {
if (e.key === 'Enter') calculateBMI();
});
<\/script>
</body>
</html>`;
}
function generateTodo() {
return `<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>To-Do List App</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 40px 20px;
}
.container {
max-width: 500px;
margin: 0 auto;
background: white;
border-radius: 20px;
padding: 30px;
box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
h1 {
text-align: center;
color: #333;
margin-bottom: 30px;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
.input-group {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
input[type="text"] {
flex: 1;
padding: 14px 18px;
border: 2px solid #e0e0e0;
border-radius: 12px;
font-size: 16px;
transition: all 0.3s;
}
input[type="text"]:focus {
outline: none;
border-color: #667eea;
}
button.add {
padding: 14px 24px;
background: #667eea;
color: white;
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
}
button.add:hover {
background: #764ba2;
transform: scale(1.05);
}
.stats {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
padding: 15px;
background: #f3f4f6;
border-radius: 10px;
font-size: 14px;
color: #6b7280;
}
ul { list-style: none; }
li {
display: flex;
align-items: center;
padding: 16px;
background: #f9fafb;
border-radius: 12px;
margin-bottom: 10px;
transition: all 0.3s;
animation: slideIn 0.3s ease;
}
@keyframes slideIn {
from { opacity: 0; transform: translateX(-20px); }
to { opacity: 1; transform: translateX(0); }
}
li:hover {
background: #f3f4f6;
transform: translateX(5px);
}
li.completed {
opacity: 0.6;
}
li.completed span {
text-decoration: line-through;
color: #9ca3af;
}
input[type="checkbox"] {
width: 20px;
height: 20px;
margin-right: 15px;
cursor: pointer;
accent-color: #667eea;
}
span {
flex: 1;
color: #374151;
font-size: 16px;
}
button.delete {
background: #ef4444;
color: white;
border: none;
padding: 8px 16px;
border-radius: 8px;
cursor: pointer;
font-size: 14px;
opacity: 0;
transition: all 0.3s;
}
li:hover button.delete {
opacity: 1;
}
button.delete:hover {
background: #dc2626;
}
.empty {
text-align: center;
padding: 40px;
color: #9ca3af;
}
</style>
</head>
<body>
<div class="container">
<h1>✅ To-Do List</h1>
<div class="input-group">
<input type="text" id="taskInput" placeholder="Tambahkan tugas baru..." maxlength="100">
<button class="add" onclick="addTask()">Tambah</button>
</div>
<div class="stats">
<span id="totalTasks">Total: 0</span>
<span id="completedTasks">Selesai: 0</span>
</div>
<ul id="taskList">
<div class="empty">Belum ada tugas. Tambahkan tugas pertama Anda! 📝</div>
</ul>
</div>
<script>
let tasks = JSON.parse(localStorage.getItem('tasks')) || [];
function saveTasks() {
localStorage.setItem('tasks', JSON.stringify(tasks));
updateStats();
}
function updateStats() {
const total = tasks.length;
const completed = tasks.filter(t => t.completed).length;
document.getElementById('totalTasks').textContent = 'Total: ' + total;
document.getElementById('completedTasks').textContent = 'Selesai: ' + completed;
}
function addTask() {
const input = document.getElementById('taskInput');
const text = input.value.trim();
if (!text) {
alert('Mohon masukkan tugas!');
return;
}
const task = {
id: Date.now(),
text: text,
completed: false,
createdAt: new Date().toLocaleString('id-ID')
};
tasks.push(task);
input.value = '';
saveTasks();
renderTasks();
}
function toggleTask(id) {
const task = tasks.find(t => t.id === id);
if (task) {
task.completed = !task.completed;
saveTasks();
renderTasks();
}
}
function deleteTask(id) {
if (confirm('Hapus tugas ini?')) {
tasks = tasks.filter(t => t.id !== id);
saveTasks();
renderTasks();
}
}
function renderTasks() {
const list = document.getElementById('taskList');
if (tasks.length === 0) {
list.innerHTML = '<div class="empty">Belum ada tugas. Tambahkan tugas pertama Anda! 📝</div>';
return;
}
list.innerHTML = tasks.map(task => {
return '<li class="' + (task.completed ? 'completed' : '') + '">' +
'<input type="checkbox" ' + (task.completed ? 'checked' : '') + ' onchange="toggleTask(' + task.id + ')">' +
'<span>' + escapeHtml(task.text) + '</span>' +
'<button class="delete" onclick="deleteTask(' + task.id + ')">Hapus</button>' +
'</li>';
}).join('');
}
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
document.getElementById('taskInput').addEventListener('keypress', function(e) {
if (e.key === 'Enter') addTask();
});
updateStats();
renderTasks();
<\/script>
</body>
</html>`;
}
function generateGame() {
return `<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Snake Game</title>
<style>
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
font-family: 'Courier New', monospace;
}
.game-container {
text-align: center;
}
.score-board {
color: white;
font-size: 24px;
margin-bottom: 15px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
canvas {
border: 4px solid #fff;
border-radius: 10px;
background: #111;
box-shadow: 0 0 30px rgba(0,255,0,0.3);
}
.controls {
color: #aaa;
margin-top: 20px;
font-size: 14px;
}
button {
background: #4CAF50;
color: white;
border: none;
padding: 12px 30px;
font-size: 16px;
border-radius: 25px;
cursor: pointer;
margin-top: 15px;
transition: all 0.3s;
}
button:hover {
background: #45a049;
transform: scale(1.05);
}
</style>
</head>
<body>
<div class="game-container">
<div class="score-board">Score: <span id="score">0</span> | High Score: <span id="highScore">0</span></div>
<canvas id="game" width="400" height="400"></canvas>
<div class="controls">Gunakan arrow keys untuk bergerak</div>
<button onclick="resetGame()">🔄 Main Lagi</button>
</div>
<script>
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
const gridSize = 20;
const tileCount = canvas.width / gridSize;
let snake = [{x: 10, y: 10}];
let food = {x: 15, y: 15};
let dx = 0;
let dy = 0;
let score = 0;
let highScore = localStorage.getItem('snakeHighScore') || 0;
let gameLoop;
let isGameOver = false;
document.getElementById('highScore').textContent = highScore;
document.addEventListener('keydown', changeDirection);
function changeDirection(e) {
if (isGameOver) return;
const LEFT = 37, UP = 38, RIGHT = 39, DOWN = 40;
switch(e.keyCode) {
case LEFT: if (dx !== 1) { dx = -1; dy = 0; } break;
case UP: if (dy !== 1) { dx = 0; dy = -1; } break;
case RIGHT: if (dx !== -1) { dx = 1; dy = 0; } break;
case DOWN: if (dy !== -1) { dx = 0; dy = 1; } break;
}
}
function drawGame() {
if (isGameOver) return;
ctx.fillStyle = '#111';
ctx.fillRect(0, 0, canvas.width, canvas.height);
const head = {x: snake[0].x + dx, y: snake[0].y + dy};
if (head.x < 0 || head.x >= tileCount || head.y < 0 || head.y >= tileCount) {
endGame();
return;
}
for (let i = 0; i < snake.length; i++) {
if (head.x === snake[i].x && head.y === snake[i].y) {
endGame();
return;
}
}
snake.unshift(head);
if (head.x === food.x && head.y === food.y) {
score += 10;
document.getElementById('score').textContent = score;
if (score > highScore) {
highScore = score;
localStorage.setItem('snakeHighScore', highScore);
document.getElementById('highScore').textContent = highScore;
}
placeFood();
canvas.style.boxShadow = '0 0 50px rgba(0,255,0,0.8)';
setTimeout(() => {
canvas.style.boxShadow = '0 0 30px rgba(0,255,0,0.3)';
}, 200);
} else {
snake.pop();
}
snake.forEach((segment, index) => {
ctx.fillStyle = index === 0 ? '#0f0' : '#0a0';
ctx.fillRect(segment.x * gridSize, segment.y * gridSize, gridSize - 2, gridSize - 2);
if (index === 0) {
ctx.fillStyle = '#fff';
ctx.fillRect(segment.x * gridSize + 5, segment.y * gridSize + 5, 3, 3);
ctx.fillRect(segment.x * gridSize + 12, segment.y * gridSize + 5, 3, 3);
}
});
ctx.fillStyle = '#f00';
ctx.beginPath();
ctx.arc(food.x * gridSize + gridSize/2, food.y * gridSize + gridSize/2, gridSize/2 - 2, 0, Math.PI * 2);
ctx.fill();
}
function placeFood() {
food = {
x: Math.floor(Math.random() * tileCount),
y: Math.floor(Math.random() * tileCount)
};
for (let i = 0; i < snake.length; i++) {
if (food.x === snake[i].x && food.y === snake[i].y) {
placeFood();
return;
}
}
}
function endGame() {
isGameOver = true;
clearInterval(gameLoop);
ctx.fillStyle = 'rgba(0,0,0,0.8)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#fff';
ctx.font = 'bold 40px Courier New';
ctx.textAlign = 'center';
ctx.fillText('GAME OVER', canvas.width/2, canvas.height/2 - 20);
ctx.font = '20px Courier New';
ctx.fillText('Score: ' + score, canvas.width/2, canvas.height/2 + 20);
}
function resetGame() {
snake = [{x: 10, y: 10}];
dx = 0;
dy = 0;
score = 0;
isGameOver = false;
document.getElementById('score').textContent = score;
placeFood();
if (gameLoop) clearInterval(gameLoop);
gameLoop = setInterval(drawGame, 100);
}
resetGame();
<\/script>
</body>
</html>`;
}
function generatePortfolio() {
return `<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Portfolio - Full Stack Developer</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
font-family: 'Segoe UI', system-ui, sans-serif;
line-height: 1.6;
color: #333;
}
.hero {
min-height: 100vh;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
color: white;
padding: 20px;
position: relative;
}
.hero::before {
content: '';
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-content { position: relative; z-index: 1; animation: fadeInUp 1s ease; }
@keyframes fadeInUp {
from { opacity: 0; transform: translateY(30px); }
to { opacity: 1; transform: translateY(0); }
}
.hero h1 { font-size: 3.5rem; margin-bottom: 20px; font-weight: 700; }
.hero p { font-size: 1.3rem; margin-bottom: 40px; opacity: 0.9; }
.btn {
display: inline-block;
padding: 15px 40px;
background: white;
color: #667eea;
text-decoration: none;
border-radius: 50px;
font-weight: 600;
transition: all 0.3s;
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.btn:hover { transform: translateY(-3px); box-shadow: 0 15px 40px rgba(0,0,0,0.3); }
.section { padding: 100px 20px; max-width: 1200px; margin: 0 auto; }
.section-title {
text-align: center;
font-size: 2.5rem;
margin-bottom: 60px;
color: #333;
position: relative;
}
.section-title::after {
content: '';
display: block;
width: 60px;
height: 4px;
background: linear-gradient(135deg, #667eea, #764ba2);
margin: 20px auto;
border-radius: 2px;
}
.skills-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 30px;
}
.skill-card {
background: white;
padding: 40px;
border-radius: 20px;
box-shadow: 0 10px 40px rgba(0,0,0,0.1);
text-align: center;
transition: all 0.3s;
}
.skill-card:hover {
transform: translateY(-10px);
box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.skill-icon { font-size: 3.5rem; margin-bottom: 20px; }
.skill-card h3 { font-size: 1.5rem; margin-bottom: 15px; color: #333; }
.skill-card p { color: #666; line-height: 1.8; }
.projects { background: #f8f9fa; }
.project-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
gap: 30px;
}
.project-card {
background: white;
border-radius: 20px;
overflow: hidden;
box-shadow: 0 10px 40px rgba(0,0,0,0.1);
transition: all 0.3s;
}
.project-card:hover { transform: scale(1.02); }
.project-image {
height: 200px;
background: linear-gradient(135deg, #667eea, #764ba2);
display: flex;
align-items: center;
justify-content: center;
font-size: 4rem;
}
.project-info { padding: 30px; }
.project-info h3 { font-size: 1.3rem; margin-bottom: 10px; }
.project-info p { color: #666; margin-bottom: 20px; }
.project-tags { display: flex; gap: 10px; flex-wrap: wrap; }
.tag {
padding: 5px 15px;
background: #e0e7ff;
color: #667eea;
border-radius: 20px;
font-size: 0.85rem;
}
.contact { background: #333; color: white; text-align: center; }
.contact .section-title { color: white; }
.contact .section-title::after { background: white; }
.social-links {
display: flex;
justify-content: center;
gap: 20px;
margin-top: 40px;
}
.social-links a {
width: 50px;
height: 50px;
background: rgba(255,255,255,0.1);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
transition: all 0.3s;
text-decoration: none;
}
.social-links a:hover { background: white; transform: translateY(-5px); }
footer { background: #222; color: #aaa; text-align: center; padding: 30px; }
@media (max-width: 768px) {
.hero h1 { font-size: 2.5rem; }
.hero p { font-size: 1.1rem; }
.section { padding: 60px 20px; }
.section-title { font-size: 2rem; }
}
</style>
</head>
<body>
<section class="hero">
<div class="hero-content">
<h1>👋 Hello, I'm Developer</h1>
<p>Full Stack Developer & UI/UX Designer</p>
<a href="#about" class="btn">Lihat Portfolio</a>
</div>
</section>
<section id="about" class="section">
<h2 class="section-title">Keahlian Saya</h2>
<div class="skills-grid">
<div class="skill-card">
<div class="skill-icon">💻</div>
<h3>Web Development</h3>
<p>HTML5, CSS3, JavaScript ES6+, React, Node.js, Express, MongoDB</p>
</div>
<div class="skill-card">
<div class="skill-icon">🎨</div>
<h3>UI/UX Design</h3>
<p>Figma, Adobe XD, Prototyping, Wireframing, User Research</p>
</div>
<div class="skill-card">
<div class="skill-icon">📱</div>
<h3>Mobile Development</h3>
<p>React Native, Flutter, Responsive Design, PWA</p>
</div>
</div>
</section>
<section class="section projects">
<h2 class="section-title">Proyek Terbaru</h2>
<div class="project-grid">
<div class="project-card">
<div class="project-image">🛒</div>
<div class="project-info">
<h3>E-Commerce Platform</h3>
<p>Platform e-commerce lengkap dengan payment gateway dan dashboard admin.</p>
<div class="project-tags">
<span class="tag">React</span>
<span class="tag">Node.js</span>
<span class="tag">MongoDB</span>
</div>
</div>
</div>
<div class="project-card">
<div class="project-image">📊</div>
<div class="project-info">
<h3>Analytics Dashboard</h3>
<p>Dashboard analitik real-time dengan visualisasi data interaktif.</p>
<div class="project-tags">
<span class="tag">Vue.js</span>
<span class="tag">D3.js</span>
<span class="tag">Firebase</span>
</div>
</div>
</div>
<div class="project-card">
<div class="project-image">🤖</div>
<div class="project-info">
<h3>AI Chatbot</h3>
<p>Chatbot AI untuk customer service dengan NLP.</p>
<div class="project-tags">
<span class="tag">Python</span>
<span class="tag">TensorFlow</span>
<span class="tag">Flask</span>
</div>
</div>
</div>
</div>
</section>
<section class="section contact">
<h2 class="section-title">Mari Berkolaborasi</h2>
<p style="font-size: 1.2rem; opacity: 0.9;">Tertarik bekerja sama? Hubungi saya!</p>
<p style="margin-top: 20px; font-size: 1.5rem;">📧 hello@developer.com</p>
<div class="social-links">
<a href="#">📱</a>
<a href="#">💼</a>
<a href="#">🐦</a>
<a href="#">📸</a>
</div>
</section>
<footer>
<p>© 2024 Portfolio. Built with ❤️ using HTML & CSS</p>
</footer>
</body>
</html>`;
}
function generatePython(input) {
return `# AI Generated Python Script
# Generated by: AI Programming Assistant (Tomi)
# Request: ${input}
# Date: ${new Date().toLocaleString()}
import random
import datetime
from typing import List, Dict, Any, Optional
from dataclasses import dataclass
@dataclass
class DataRecord:
"""Data structure for records"""
id: int
value: float
timestamp: datetime.datetime
category: str
class SmartProcessor:
"""
Intelligent data processor with AI capabilities
"""
def __init__(self, name: str = "AI Processor"):
self.name = name
self.version = "2.0.0"
self.records: List[DataRecord] = []
self.created_at = datetime.datetime.now()
def generate_sample_data(self, count: int = 10) -> List[DataRecord]:
"""Generate random sample data"""
categories = ["A", "B", "C", "D"]
for i in range(count):
record = DataRecord(
id=i + 1,
value=random.uniform(1.0, 100.0),
timestamp=datetime.datetime.now(),
category=random.choice(categories)
)
self.records.append(record)
return self.records
def analyze(self) -> Dict[str, Any]:
"""Perform comprehensive data analysis"""
if not self.records:
return {"error": "No data available"}
values = [r.value for r in self.records]
return {
"count": len(self.records),
"sum": round(sum(values), 2),
"average": round(sum(values) / len(values), 2),
"min": round(min(values), 2),
"max": round(max(values), 2),
"std_dev": round(self._calculate_std(values), 2),
"categories": self._category_breakdown()
}
def _calculate_std(self, values: List[float]) -> float:
"""Calculate standard deviation"""
if len(values) < 2:
return 0.0
mean = sum(values) / len(values)
variance = sum((x - mean) ** 2 for x in values) / len(values)
return variance ** 0.5
def _category_breakdown(self) -> Dict[str, int]:
"""Count records by category"""
breakdown = {}
for record in self.records:
breakdown[record.category] = breakdown.get(record.category, 0) + 1
return breakdown
def export_report(self) -> str:
"""Generate formatted report"""
analysis = self.analyze()
report = f"""
{'='*50}
{self.name} v{self.version} - Analysis Report
Generated: {datetime.datetime.now()}
{'='*50}
SUMMARY STATISTICS:
- Total Records: {analysis['count']}
- Sum: {analysis['sum']}
- Average: {analysis['average']}
- Min: {analysis['min']}
- Max: {analysis['max']}
- Std Dev: {analysis['std_dev']}
CATEGORY BREAKDOWN:
"""
for cat, count in analysis['categories'].items():
report += f"- Category {cat}: {count} records\\n"
report += f"{'='*50}\\n"
return report
def main():
"""Main execution function"""
print("🤖 AI Programming Assistant - Python Generator")
print("=" * 50)
# Initialize processor
processor = SmartProcessor("Tomi's AI")
# Generate data
print("\\n📊 Generating sample data...")
data = processor.generate_sample_data(20)
print(f"Generated {len(data)} records")
# Analyze
print("\\n🔍 Analyzing data...")
analysis = processor.analyze()
# Display results
print("\\n📈 Results:")
for key, value in analysis.items():
if key != 'categories':
print(f" {key}: {value}")
# Export report
print("\\n" + processor.export_report())
print("✅ Processing complete!")
if __name__ == "__main__":
main()`;
}
function generateDefault(input) {
return `<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Generated App</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Segoe UI', system-ui, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
background: white;
padding: 50px;
border-radius: 24px;
box-shadow: 0 25px 50px rgba(0,0,0,0.2);
max-width: 600px;
width: 100%;
text-align: center;
animation: slideUp 0.5s ease;
}
@keyframes slideUp {
from { opacity: 0; transform: translateY(30px); }
to { opacity: 1; transform: translateY(0); }
}
.icon { font-size: 4rem; margin-bottom: 20px; }
h1 { color: #333; font-size: 2rem; margin-bottom: 15px; }
p { color: #666; line-height: 1.8; margin-bottom: 30px; }
.features { text-align: left; margin: 30px 0; }
.feature {
display: flex;
align-items: center;
gap: 15px;
padding: 15px;
background: #f8f9fa;
border-radius: 12px;
margin-bottom: 10px;
transition: transform 0.3s;
}
.feature:hover { transform: translateX(5px); }
.feature-icon { font-size: 1.5rem; }
.btn {
display: inline-block;
padding: 15px 40px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
text-decoration: none;
border-radius: 30px;
font-weight: 600;
transition: all 0.3s;
}
.btn:hover {
transform: translateY(-3px);
box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}
</style>
</head>
<body>
<div class="container">
<div class="icon">🚀</div>
<h1>${input.substring(0, 50)}...</h1>
<p>Aplikasi web modern yang dihasilkan oleh AI Programming Assistant oleh Tomi. Desain responsif dengan animasi smooth dan user experience terbaik.</p>
<div class="features">
<div class="feature">
<span class="feature-icon">⚡</span>
<div>
<strong>Performa Tinggi</strong>
<div style="color: #666; font-size: 0.9rem;">Optimasi kecepatan loading</div>
</div>
</div>
<div class="feature">
<span class="feature-icon">📱</span>
<div>
<strong>Responsive Design</strong>
<div style="color: #666; font-size: 0.9rem;">Tampilan sempurna di semua device</div>
</div>
</div>
<div class="feature">
<span class="feature-icon">🎨</span>
<div>
<strong>Modern UI/UX</strong>
<div style="color: #666; font-size: 0.9rem;">Interface yang bersih dan intuitif</div>
</div>
</div>
</div>
<a href="#" class="btn" onclick="alert('Fitur akan segera hadir! 🎉')">Mulai Sekarang</a>
</div>
</body>
</html>`;
}
// UI Functions
function displayCode(code, filename) {
document.getElementById('filename').textContent = filename;
let highlighted = code
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/(".*?")/g, '<span class="syntax-string">$1</span>')
.replace(/('.*?')/g, '<span class="syntax-string">$1</span>')
.replace(/\b(function|return|var|let|const|if|else|for|while|class|import|from|def|print|async|await|try|catch|class|extends)\b/g, '<span class="syntax-keyword">$1</span>')
.replace(/\b(console|document|window|Math|Date|JSON|localStorage|fetch|alert|parseFloat|parseInt)\b/g, '<span class="syntax-function">$1</span>')
.replace(/(\/\/.*$|#.*$|<!--.*?-->)/gm, '<span class="syntax-comment">$1</span>')
.replace(/\b(\d+)\b/g, '<span class="syntax-number">$1</span>');
document.getElementById('codeDisplay').innerHTML = '<code>' + highlighted + '</code>';
}
function updatePreview(code) {
const frame = document.getElementById('previewFrame');
const blob = new Blob([code], { type: 'text/html' });
const url = URL.createObjectURL(blob);
frame.src = url;
}
function refreshPreview() {
const code = document.getElementById('codeDisplay').textContent;
if (code && code !== '// Kode akan muncul di sini...') {
updatePreview(code);
}
}
function copyCode() {
const code = document.getElementById('codeDisplay').textContent;
if (!code || code === '// Kode akan muncul di sini...') return;
navigator.clipboard.writeText(code).then(() => {
showToast('✅ Kode berhasil disalin!');
});
}
function downloadCode() {
const code = document.getElementById('codeDisplay').textContent;
const filename = document.getElementById('filename').textContent;
if (!code || code === '// Kode akan muncul di sini...') return;
const blob = new Blob([code], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
showToast('✅ File berhasil diunduh!');
}
function clearAll() {
document.getElementById('userInput').value = '';
document.getElementById('codeDisplay').innerHTML = '<code>// Kode akan muncul di sini...</code>';
document.getElementById('previewFrame').src = '';
document.getElementById('outputSection').classList.add('hidden');
document.getElementById('filename').textContent = 'index.html';
}
function showToast(message) {
const toast = document.getElementById('toast');
const toastMessage = document.getElementById('toastMessage');
toastMessage.textContent = message;
toast.classList.remove('hidden');
setTimeout(() => {
toast.classList.add('hidden');
}, 3000);
}
// Enter key support
document.getElementById('userInput').addEventListener('keypress', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
generateCode();
}
});
</script>
</body>
</html>